为Localhost Ampps添加虚拟主机 [英] Add Virtual Host for Localhost Ampps
问题描述
<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>
如何将特定的域"(虚拟主机域)绑定到一个位置?上面的proj.local也指向localhost.
How do I bind a specific "domain" (virtual host domain) to one location? Above points proj.local to localhost as well.
推荐答案
正如您说的那样,您正在使用AMPPS,我想您是将以下说明添加到该文件夹中:
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>
好的.完成此操作后,您将必须添加到主机文件.在Mac中,它们位于:
All right. After doing that, you will have to add to your hosts file. In Mac they are located in:
/etc/hosts
如果您使用的是Windows环境,则会在以下位置找到主机文件:
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.
然后,您将在其中添加本地IP和主机名.就是这样:
Then you'll add your local IP and the hostname to it. Just like this:
127.0.0.1 project.local
如果您没有将URL添加到无法使用的主机文件中.
If you don't add the URL to the hosts file that won't work.
这篇关于为Localhost Ampps添加虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!