我正在 Mac OS X 上使用 XAMPP。
我正在尝试运行 Symfony正确地为客户提供网站,但我真的不了解 Symfony(还)。我只想安装并启动它。
我已经改变了我的 /etc/hosts 这样归档:
127.0.0.1 www.mysite.local
httpd.conf 文件如下:
<VirtualHost *:80>
ServerName www.mysite.local
DocumentRoot /Applications/MAMP/htdocs/mysite/web
DirectoryIndex index.php
<Directory /Applications/MAMP/htdocs/mysite/web>
AllowOverride All
Allow from All
</Directory>
Alias /sf /Applications/MAMP/htdocs/mysite/lib/vendor/symfony/data/web/sf
<Directory "/Applications/MAMP/htdocs/mysite/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
现在,该网站正在运行(耶!),但我无法再访问任何其他本地网站,因为 localhost 呈现为 www.mysite.local 。
我哪里错了?
最佳答案
这对我有用!
要运行http://localhost/projectName
之类的项目:
<VirtualHost localhost:80>
ServerAdmin localhost
DocumentRoot path/to/htdocs/
ServerName localhost
</VirtualHost>
要在本地运行 http://somewebsite.com
等项目:
<VirtualHost somewebsite.com:80>
ServerAdmin webmaster@example.com
DocumentRoot /path/to/htdocs/somewebsiteFolder
ServerName www.somewebsite.com
ServerAlias somewebsite.com
</VirtualHost>
其他网站也是如此:
<VirtualHost anothersite.local:80>
ServerAdmin webmaster@example.com
DocumentRoot /path/to/htdocs/anotherSiteFolder
ServerName www.anothersite.local
ServerAlias anothersite.com
</VirtualHost>
关于Apache 虚拟主机和本地主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10981174/