2016-11-21 110 views
0

问题:自从我升级到Sierra后,我无法连接到本地主机。我之前使用过MAMP,但一旦升级后它就停止工作,当我无法再次使用mysql时,我决定使用apache/php/mysql设置默认localhost,但现在已经差不多一周了,而且我无法似乎得到正确的配置!在整个事情完全丧失的情况下,在这一点上,任何帮助都将不胜感激。Localhost配置mac塞拉利昂

什么我迄今所做..

-Removed MAMP的所有实例包括.bash_profile中删除。我的道路现在看起来是这样,

export PATH="/usr/local/mysql/bin:$PATH" 

-I mysql安装,并通过系统首选项面板可以打开和关闭它。 - 我升级到php7。所以我现在已经安装了php5和php7。 -I建立了一套username.conf(当然,我换出用户名我的实际用户名)

<Directory "/Users/username/Sites/"> 
Options Indexes MultiViews 
AllowOverride All 
Order allow,deny 
Allow from all 
</Directory> 

-I设置一个虚拟主机,

<VirtualHost *:80> 
DocumentRoot "/Users/username/Sites" 
ServerName localhost 
</VirtualHost> 

-I取消注释中的httpd。 CONF,

LoadModule userdir_module libexec/apache2/mod_userdir.so 
LoadModule include_module libexec/apache2/mod_include.so 
LoadModule rewrite_module libexec/apache2/mod_rewrite.so 
LoadModule cgi_module libexec/apache2/mod_cgi.so 
LoadModule php5_module libexec/apache2/libphp5.so 
Include /private/etc/apache2/extra/httpd-userdir.conf 
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so 

在的httpd-userdir.conf -Uncommented,

Include /private/etc/apache2/users/*.conf 

在虚拟主机发生变化之前,我可以访问“It Worked!”在浏览器中,但现在它说

localhost拒绝连接。

我还试图移动我的项目之一的文档文件夹和公正的工作就可以从默认的“本地主机”,而无需使用username.conf,但我无法得到该项目,即使打开“有用!”页面正在加载,很奇怪。

在httpd.conf DocumentRoot的是/库/ Web服务器/文件

我不想改变这/用户/用户名/网站(如我以前),因为我想使用的用户名。 conf访问目录,例如:当我在浏览器中输入“localhost”时,应该说“It Works!”当我输入“localhost /〜username”时,应该说“欢迎来自你的用户目录”。我知道这一定很简单,可能只需要做一个小小的改变,有没有人知道我做错了什么?

我在终端得到什么:

的httpd -v

Server version: Apache/2.4.23 (Unix) 
Server built: Aug 8 2016 16:31:34 

的apachectl -S

VirtualHost configuration: 
*:80     is a NameVirtualHost 
     default server localhost (/private/etc/apache2/extra/httpd-vhosts.conf:24) 
     port 80 namevhost localhost (/private/etc/apache2/extra/httpd-vhosts.conf:24) 
     port 80 namevhost dummy-host.example.com (/private/etc/apache2/extra/httpd-vhosts.conf:29) 
       alias www.dummy-host.example.com 
     port 80 namevhost dummy-host2.example.com (/private/etc/apache2/extra/httpd-vhosts.conf:38) 
ServerRoot: "/usr" 
Main DocumentRoot: "/Library/WebServer/Documents" 
Main ErrorLog: "/private/var/log/apache2/error_log" 
Mutex mpm-accept: using_defaults 
Mutex proxy-balancer-shm: using_defaults 
Mutex rewrite-map: using_defaults 
Mutex proxy: using_defaults 
Mutex default: dir="/private/var/run/" mechanism=default 
PidFile: "/private/var/run/httpd.pid" 
Define: DUMP_VHOSTS 
Define: DUMP_RUN_CFG 
User: name="_www" id=70 not_used 
Group: name="_www" id=70 not_used 

的PHP

/usr/bin/php 

其中MySQL的

/usr/local/mysql/bin/mysql 

PHP -v

PHP 5.6.25 (cli) (built: Sep 6 2016 16:37:16) 
Copyright (c) 1997-2016 The PHP Group 
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies 

回声$ PATH

/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin 

..所以,你可以看到本地主机没有被阿帕奇回升。

我已经通过许多后解决方案,但似乎没有任何工作。我也已将所有内容重置为默认设置,并再次进行更改以查看是否错过了任何内容,但没有运气。

我不想在“主机”文件中更改任何内容,以防万一我把所有东西搞砸了,是我错过了什么?

(看来我只能在这里发布两个链接,但显然我已经通过了很多更多的问题/教程比这个!)这两个看起来像他们应该能够解决这个问题。 Apache localhost/~username/ not working https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/

再次感谢您的时间,我希望有人在那里可以点我在正确的方向。

回答

1

如果仍然相关。 如果您只是试图在没有仿真工具的情况下设置本地主机,比如模拟其他服务器等,则无需查看虚拟主机。默认情况下,localhost正在监听端口80,并且它已准备好供您使用,您只需指定谁可以访问它,当然,请不要忘记使用sudo模式的apachectl start apache,我认为这很奇怪,因为获得本地主机工作,你只需要启动Apache,它应该说'它的工作!'在进入浏览器之后。

如果您指定用户目录,请注意您正在使用的apache版本,因此对于Siera,您的username.conf应该如下所示。

<Directory "/Users/username/Sites/"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride All 
    Require all granted 
</Directory> 

再次使用sudo权限执行apachectl restart。如果问题仍然存在,请运行apachectl configtest并在此处粘贴内容。

+0

感谢您的回复@Azureus。我已经解决了这个问题,但你的建议肯定会帮助下一个被卡住的人! – Shani