我已经在我的小牛上安装了xampp,我已经完成了虚拟主机的配置,即使我认为我会自己做,但它仍然无法正常工作。我无法在任何地方找到问题,我查看了可能与之有关的所有文件,重写/etc/hosts
文件../xamppfiles/etc/extra/httpd-vhosts.conf
和../xamppfiles/etc/httpd.conf
但是当我去浏览器和我键入我的vhosts指定的地址它不起作用,它引发了我谷歌搜索。我也尝试添加另一个vhost,但同样的事情发生了。
我的vhosts文件如下所示: NameVirtualHost *:80
# localhost
<VirtualHost *:80>
ServerName "localhost"
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/xampp"
<Directory "/Applications/XAMPP/xamppfiles/htdocs/xampp">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Allow From All
Order Allow,Deny
</Directory>
</VirtualHost>
# My custom host
<VirtualHost *:80>
ServerName "site1.local"
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/site1"
<Directory "/Applications/XAMPP/xamppfiles/htdocs/site1">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
ErrorLog "Applications/XAMPP/xamppfiles/htdocs/site1/site1.local-error_log"
</VirtualHost>
我还将此行添加到hosts文件的底部:
# XAMPP VirtualHost mappings
127.0.0.1 site1.local
并取消注释httpd.conf中的行
Include etc/extra/httpd-vhosts.conf
我通过将.htaccess文件重命名为htaccess并注释掉所有内容来禁用它。
我真的不知道还能做什么,但仍然无效: - /
我没有忘记分别重启apache服务器。
答案 0 :(得分:1)
您的vhost文件缺少反斜杠。它应该看起来像:
# localhost <VirtualHost *:80> ServerName "localhost" DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/xampp" <Directory "/Applications/XAMPP/xamppfiles/htdocs/xampp/"> Options Indexes FollowSymLinks Includes execCGI AllowOverride All Allow From All Order Allow,Deny </Directory> </VirtualHost> # My custom host <VirtualHost *:80> ServerName "site1.local" DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/site1" <Directory "/Applications/XAMPP/xamppfiles/htdocs/site1/"> Options Indexes FollowSymLinks Includes ExecCGI Order allow,deny Allow from all AllowOverride All Require all granted </Directory> ErrorLog "Applications/XAMPP/xamppfiles/htdocs/site1/site1.local-error_log" </VirtualHost>
添加到您的浏览器
http://site1.local/
它应该工作。