2014-09-30 42 views
5

WAMP虛擬主機是2.4.9 PHP:5.5.12 MySQL的:5.6.17我使用的是WAMP版本2.5 我的Apache不工作

我有以下配置:

在我httpd.conf

# Virtual hosts 
Include conf/extra/httpd-vhosts.conf 

在我G:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhost.conf

# Virtual Hosts 
# 
# Required modules: mod_log_config 

# If you want to maintain multiple domains/hostnames on your 
# machine you can setup VirtualHost containers for them. Most configurations 
# use only name-based virtual hosts so the server doesn't need to worry about 
# IP addresses. This is indicated by the asterisks in the directives below. 
# 
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/> 
# for further details before you try to setup virtual hosts. 
# 
# You may use the command line option '-S' to verify your virtual host 
# configuration. 
# 


# 
# VirtualHost example: 
# Almost any Apache directive may go into a VirtualHost container. 
# The first VirtualHost section is used for all requests that do not 
# match a ServerName or ServerAlias in any <VirtualHost> block. 
# 


<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "g:/Apache24/docs/dummy-host.example.com" 
    ServerName dummy-host.example.com 
    ServerAlias www.dummy-host.example.com 
    ErrorLog "logs/dummy-host.example.com-error.log" 
    CustomLog "logs/dummy-host.example.com-access.log" common 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "g:/Apache24/docs/dummy-host2.example.com" 
    ServerName dummy-host2.example.com 
    ErrorLog "logs/dummy-host2.example.com-error.log" 
    CustomLog "logs/dummy-host2.example.com-access.log" common 
</VirtualHost> 


<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "g:/wamp/www" 
    ServerName localhost 
    ErrorLog "logs/localhost-error.log" 
    CustomLog "logs/localhost-access.log" common 
</VirtualHost> 

<VirtualHost *:80> 
    DocumentRoot "g:\wamp\www\mysite\public" 
    ServerName mysite.dev 
</VirtualHost> 

在我c:\Windows\System32\Drivers\etc\hosts

# localhost name resolution is handled within DNS itself. 
127.0.0.1 localhost 
127.0.0.1 mysite.dev 
# ::1  localhost 

我嘗試使用這個URL來訪問我的項目:http://www.mysite.dev/我得到一個Server not found error我試圖訪問它使用www.mysite.devhttp://mysite.dev但仍然有運氣不好!

我的虛擬主機之前工作,但我不知道爲什麼它現在不工作。一些奇怪的東西在繼續。

我不確定發生了什麼事。任何想法將不勝感激!

謝謝!

+0

你試過類似[this](http://stackoverflow.com/a/11154840/2518525)嗎? – Darren 2014-09-30 05:34:11

+0

在url中只使用mysite.dev。並檢查 – 2014-09-30 05:36:02

+0

還檢查你的mysite \ public是否有index.php? – 2014-09-30 05:37:14

回答

-1

試試這個你的apache httpd.config文件:

<VirtualHost *:80> 
     ServerName mysite.dev 
     DocumentRoot "g:\wamp\www\mysite\public" 
    SetEnv APPLICATION_ENV "development" 

    <Directory "g:\wamp\www\mysite\public"> 
     DirectoryIndex index.php 
     Options All Includes Indexes 
     Options All Indexes FollowSymLinks 
     Order allow,deny 
     Allow from all 
     Require all granted 
    </Directory> 
    </VirtualHost> 

重新啓動WAMP的服務器,並把網址就像你的瀏覽器mysite.dev/。希望它能幫助你。 謝謝。

10

首先,您需要從您的vhost-httpd.conf文件中刪除示例dummy定義。它們僅作爲示例只是爲了讓您開始使用語法,並且不應將它們保留在活動的conf/extra/httpd-vhosts.conf中,因爲它們指向不存在的文件夾。

因此,從文件中刪除這兩個定義:

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "g:/Apache24/docs/dummy-host.example.com" 
    ServerName dummy-host.example.com 
    ServerAlias www.dummy-host.example.com 
    ErrorLog "logs/dummy-host.example.com-error.log" 
    CustomLog "logs/dummy-host.example.com-access.log" common 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "g:/Apache24/docs/dummy-host2.example.com" 
    ServerName dummy-host2.example.com 
    ErrorLog "logs/dummy-host2.example.com-error.log" 
    CustomLog "logs/dummy-host2.example.com-access.log" common 
</VirtualHost> 

二阿帕奇2.4.x的是IPV4(127.0.0.1)和IPV6(:: 1)知道讓你hosts文件應該是這樣的定義與適用於每個站點的IPV4和IPV6版本。瀏覽器可以任意使用,所以你需要兩者,但如果兩者都在你的PC上運行,可能會優先使用IPV6網絡。

127.0.0.1 localhost 
::1 localhost 

127.0.0.1 mysite.dev 
::1 mysite.dev 

現在在2臺虛擬主機,實際上存在於您的系統上嘗試以此爲虛擬主機定義:

<VirtualHost *:80> 
    DocumentRoot "g:/wamp/www" 
    ServerName localhost 
    ServerAlias localhost 
    ErrorLog "logs/localhost-error.log" 
    CustomLog "logs/localhost-access.log" common 
    <Directory "G:/wamp/www"> 
     AllowOverride All 
     Options Indexes FollowSymLinks 
     Require local 
    </Directory> 
</VirtualHost> 

<VirtualHost *:80> 
    DocumentRoot "g:\wamp\www\mysite\public" 
    ServerName mysite.dev 
    ServerAlias www.mysite.dev 
    ErrorLog "logs/mysite-error.log" 
    CustomLog "logs/mysite-access.log" common 
    <Directory "G:/wamp/www/mysite/public"> 
     AllowOverride All 
     Options Indexes FollowSymLinks 
     Require local 
    </Directory> 
</VirtualHost> 

<VirtualHost>....</VirtualHost>段內的<Directory>....</Directory>節告訴Apache是​​哪個IP地址,這是允許接受連接,所以使用Apache 2.4語法Require local限制訪問權限,以便只有運行WAMPServer(即Apache)的PC才能連接到這些站點中的任何一個。

避免在相同的定義中混合使用Apache 2.2語法和Apache 2.4語法。所以不要在同一個定義中使用

Order Allow,Deny 
Allow from all 

Require all granted 

。您正在使用Apache 2.4,因此請使用Apache 2.4語法。

如果您發現您希望允許其他PC在您的本地網絡中查看您的網站,即工作夥伴或孩子等,您可以將此語法添加到一個或多個虛擬主機定義中。

允許只是一個單一的其他PC到您的網站

Require local 
Require ip 192.168.1.100 

或2其他電腦

Require local 
Require ip 192.168.1.100, 192.168.1.101 

或者給任何人你的本地網絡上只需要使用4個四分位數的IP的前3地址。

Require ip 192.168.1 

也避免使用,允許從接入語法的任何地方,即

Require all granted <--Apache 2.4 syntax 

or 

Order Allow,Deny  <-- Apache 2.2 syntax 
Allow from all  

它可以解決您的問題,在短期內,但只是在等待,當你決定要到某個時候抓住你後將您的網站展示給朋友/客戶/老闆。如果您進入端口轉發階段,您的路由器將允許全球進入您的網絡,這將導致您的網絡全部投入使用所有網站

更好地更改ONE網站的ONE虛擬主機定義,您希望人們從Require localRequire all granted之間看到測試/吹牛,並且只允許該單個網站從互聯網訪問。

一旦你做出所有這些改變,記得重啓Apache。

此外,如果您更改hosts文件以使chnages處於活動狀態,則應該從命令行的命令行重新啓動或運行這些命令,該命令行開始爲Runs as Administrator選項。

net stop dnscache 
net start dnscache 
+0

我的上帝,我不確定哪一個實際工作。 :: 1和版本中的語法差異,因爲我做了兩個更改(知道IP6的主機文件並更正了2.4配置語法)。從幾周以來我一直在掙扎(我最終沒有使用虛擬主機,而是在需要時切換站點)。非常感謝 – 2015-03-31 09:47:01

+0

感謝LOT,將:: 1添加到我的主機文件解決了問題! – 2016-09-24 20:19:14

+0

好的信息! – CrashBurn 2017-06-26 16:16:44

0

看看這個模塊在httpd.conf中註釋掉

  • proxy_module
  • proxy_http_module
2

以下是爲我工作

1

我修復相同的P通過在Apache文件夾的httpd.conf中取消註釋一些行。下面

取消註釋行:

Include conf/extra/httpd-vhosts.conf 
LoadModule vhost_alias_module modules/mod_vhost_alias.so 

保存文件並重新啓動Apache和它的工作。 非常感謝這傢伙: https://john-dugan.com/wamp-vhost-setup/

2

由於谷歌收購.dev通用頂級域名,具有.dev發展用地不再容易實現,減輕最好的辦法是你的開發領域只是重命名成。當地或東西,你喜歡。

後臺發生的事情是,本地DNS服務器將瀏覽器重定向到127.0.53.53(open cmd> nslookup yourdomain.dev),以通知最終用戶正在獲取.dev gTLD。由於hosts文件中的.dev域設置爲127.0.0.1,因此它顯示連接被拒絕。

您可以在hosts文件中將127.0.0.1更改爲127.0.53.53,並查看瀏覽器錯誤從ERR_CONNECTION_REFUSED更改爲ERR_ICANN_NAME_COLLISION。

相關問題