Virtual Host with WAMP

青春壹個敷衍的年華 提交于 2019-12-06 08:54:39

问题


I'm using Wamp 2.2, edited conf/extra/httpd-vhosts.conf edited this file to add VirtualHosts , but when I un-commented line in httpd.conf to include httpd-vhosts.conf file, after restarting Wamp doesn't starts. If I revert changes is works fine.

Any ideas why is this happening?

This is code I'm using in httpd-vhost.conf:

<VirtualHost *>
    ServerAdmin admin@localhost.com
    DocumentRoot "C:/wamp/www" # change this line with your htdocs folder
    ServerName localhost
    ServerAlias localhost
    <Directory "C:/wamp/www">
        Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

# WooCommerce Multisite
<VirtualHost dev.lo>
    ServerAdmin admin@localhost.com
    DocumentRoot "C:/wamp/www/dev"
    ServerName dev.lo
    ServerAlias dev.lo
    <Directory "C:/wamp/www/dev">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Thanks

George

Edit

As Andreas Hagen suggested, I run Apache via httpd.exe.

First error was wrong parameter for DocumentRoot, as appears comment like was taken as second parameter, when DocumentRoot accepts only one.

Then I got warning: [warn] NameVirtualHost *:80 has no VirtualHosts. Did a quick search and found very helpful question - https://serverfault.com/questions/1405/apache-2-startup-warning-namevirtualhost-80-has-no-virtualhosts


回答1:


Probably some bad config in vhosts file. Try to start apache from commandline so you get the error output. That will help you identify your problem.




回答2:


Open your hosts file (\WINDOWS\system32\drivers\etc\hosts). Add this line to the bottom:

127.0.0.1        test

This will tell your computer that any url that contains test will be routed to 127.0.0.1 (localhost).

Now open httpd.conf and add this to the very bottom of the file:

NameVirtualHost *:80  
<VirtualHost *:80>  
    DocumentRoot "c:/wamp/www/myfirstsite/"  
    ServerName testsite  
</VirtualHost> 

Now restart apache and navigate to: http://test/ (you may have to restart your browser for the changes to take effect.)

Hope this works.




回答3:


Go to C:/drive and choose wamp folder

and go to C:\wamp\bin\apache\Apache2.4.4\conf and choose httpd.conf file.

Edit with notepad and go to 58 line number

change Listen 80 and replace Listen 8181 Save file and restart your Apache server

Now check url such like this localhost:8181

I have used this hop you will be success.



来源:https://stackoverflow.com/questions/9819707/virtual-host-with-wamp

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