WAMP Virtual Hosts Setup

廉价感情. 提交于 2019-12-11 17:48:33

问题


Problem

I had WAMP running happily and decided to set up Virtual Hosts. Now WAMP won’t start (stuck on orange). There is no error log because Apache won’t start.

Also relevant: this version of WAMP listens on port 81 and MySQL uses port 3307.

Request

I have been at this for hours and cannot see my mistake. I’d be grateful if anyone can spot it.

Apache/conf/extra/httpd-vhosts

NameVirtualHost *:81

<VirtualHost *:81>
    DocumentRoot "C:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    ## Using Apache 2.4 syntax
    <Directory  "C:/wamp/www">
        Require local
        ## And possibly allow access from your local network
        ## Check you subnet for the actual values to use here
        Require ip 192.168.0
   </Directory>
</VirtualHost>


<VirtualHost *:81>
    DocumentRoot "C:/Users/Jo/My Websites/Demonstrations"
    ServerName demonstrations.com
    ServerAlias www.demonstrations.com
    Options Indexes FollowSymLinks

    ## Using Apache 2.4 syntax
    <Directory "C:/Users/Jo/My Websites/Demonstrations">
       AllowOverride All
       Require local
       #If you want to allow access from your internal network
       # For specific ip addresses add one line per ip address
       #Require ip 192.168.0.nnn
       # For every ip in the subnet, just use the first 3 numbers of the subnet
       #Require ip 192.168.0
       # If you want to allow access to everyone
       #Require all granted
    </Directory>

</VirtualHost>

Apache/conf/http.conf

DocumentRoot "c:/wamp/www/"
<Directory "c:/wamp/www/">

  Options Indexes FollowSymLinks
  AllowOverride All
  Require local

</Directory>

<Directory "C:/Users/Jo/My Websites/">
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1:81
</Directory>

AND

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

Windows/System32/drivers/etc/hosts.txt

127.0.0.1:81      localhost:81
127.0.0.1:81      demonstrators.com  #Site for demos

If anyone can spot my mistake, I would be grateful.


回答1:


Try this

First remove this entry in the httpd.conf

<Directory "C:/Users/Jo/My Websites/">
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1:81
</Directory>

Its unnecessary as this is dont in the httpd-vhost.conf file, but also you cannot use a port number on that command

Then change your host file to

127.0.0.1      localhost
127.0.0.1      demonstrators.com  #Site for demos
::1  localhost
::1  demonstrators.com 

Again ports are not used on these statements.

Once these are changed try starting Apache again.

If it fails to start this is a useful method of finding errors in the Apache config.

Start a command window, and CD to the \wamp\bin\apache\apache2.4.9\bin folder

Run this command

httpd -t

This will validate your httpd.conf and any other files that it includes and report the line number where the error is.



来源:https://stackoverflow.com/questions/25006008/wamp-virtual-hosts-setup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!