2016-11-21 106 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