【发布时间】:2023-04-08 02:39:01
【问题描述】:
我刚刚学习 Web 开发并且已经在苦苦挣扎:) 只是基础设置。
我使用的是 MacBook Air OSX 10.8.2 XAMPP 1.8.3-2 Firefox、Chrome、Safari,所有最新版本。
使用 htdocs 文件夹进行开发时一切正常,但这样我只能拥有一个站点(以及一个加载到“localhost”的 index.php 文件,不是吗?)。
我决定更改 Apache 查找文件的目录并按照说明进行操作。我编辑了 httpd.conf 文件,然后是 httpd-vhosts.conf 文件,最后是主机。重新启动 apache,检查它的配置文件是否有用户(守护进程),所以这应该不是问题。
启动 Chrome,写道: localhost - 什么都没有。 “糟糕!谷歌浏览器找不到本地主机” 然后http://testsite.local - “糟糕!谷歌浏览器找不到本地主机”
知道出了什么问题吗? 非常感谢!
httpd.conf
DocumentRoot "/Users/EdChigliak/Websites"
<Directory "/Users/EdChigliak/Websites">
httpd-vhosts.conf(注释掉 2 个虚拟主机并添加了我的自定义主机)
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
#</VirtualHost>
#<VirtualHost *:80>
#ServerAdmin webmaster@dummy-host2.example.com
#DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host2.example.com"
#ServerName dummy-host2.example.com
#ErrorLog "logs/dummy-host2.example.com-error_log"
#CustomLog "logs/dummy-host2.example.com-access_log" common
#</VirtualHost>
#localhost
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/htdocs"
<Directory "/Applications/XAMPP/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
# My custom host
<VirtualHost *:80>
ServerName probniphp.local
DocumentRoot "/Users/EdChigliak/Websites/probniphp"
<Directory "/Users/EdChigliak/Websites/probniphp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
ErrorLog "logs/mysite.local-error_log"
</VirtualHost>
【问题讨论】:
-
您是否将
probniphp.local和localhost添加到ypur hosts 文件中? (/etc/hosts) -
是的!这是:#Virtual Hosts 127.0.0.1 probniphp.local