Add Virtual Host for Localhost Ampps

浪子不回头ぞ 提交于 2019-12-25 01:54:06

问题


<VirtualHost *:80>  
    DocumentRoot "C:/Program Files (x86)/Ampps/www"
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>  
    DocumentRoot "C:/Program Files (x86)/Ampps/www/proj"
    ServerName proj.local
</VirtualHost>

How do I bind a specific "domain" (virtual host domain) to one location? Above points proj.local to localhost as well.


回答1:


Have you tried with <VirtualHOst proj.local:80>? You should be able to find more examples here: http://httpd.apache.org/docs/2.2/vhosts/examples.html




回答2:


<VirtualHost 127.0.0.1:80>
DocumentRoot "C:\xampp\htdocs"
ServerName xampp.local
ServerAlias www.xampp.local
</VirtualHost>

after adding it at the end of your httpd-vhosts.conf file restart your xampp and also add following lines to your hosts file available at C:\Windows\System32\Drivers\etc\hosts

127.0.0.1      xampp.local



回答3:


As you said you are using AMPPS, I suppose you are adding this instructions to the folder:

AMPPS/apache/conf/extra/httpd-vhosts.conf

With that in mind I'll show an example of configuration.

<VirtualHost project.local:80>
    <Directory "/Users/you/yourproject">
        Options FollowSymLinks Indexes
        AllowOverride All
        Order deny,allow
        allow from All
    </Directory>
    ServerName project.local
    ServerAlias project.local 127.0.0.1
    ScriptAlias /cgi-bin/ "/Users/you/yourproject/cgi-bin/"
    DocumentRoot "/Users/you/yourproject"
    ErrorLog "/Applications/AMPPS/apache/logs/project.error_log"
    CustomLog "/Applications/AMPPS/apache/logs/project.access.log" combined
</VirtualHost>

All right. After doing that, you will have to add to your hosts file. In Mac they are located in:

/etc/hosts

If you are using a Windows environment you will find the hosts file in:

c:\windows\system32\drivers\etc\hosts

Attention: You may have to type your password again or allow the program you're using to edit the file to use administrator privileges.

Then you'll add your local IP and the hostname to it. Just like this:

127.0.0.1      project.local

If you don't add the URL to the hosts file that won't work.



来源:https://stackoverflow.com/questions/22455403/add-virtual-host-for-localhost-ampps

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