设置 symfony 项目并更改主机文件后,非 symfony 项目不再在 apache 上运行?
我正在使用xampp。
我已经在 symfony 中设置了一个项目并将其添加到 apaches httpd.conf:
<VirtualHost 127.0.0.1:80>
ServerName www.plusoneboosters.com.localhost
DocumentRoot "C:\my_xampp\xampp\htdocs\plusoneboosters\web"
DirectoryIndex index.php
<Directory "C:\my_xampp\xampp\htdocs\plusoneboosters\web">
AllowOverride All
Allow from All
</Directory>
Alias /sf "C:\my_xampp\xampp\htdocs\plusoneboosters\lib\vendor\symfony\data\web\sf"
<Directory "C:\my_xampp\xampp\htdocs\plusoneboosters\lib\vendor\symfony\data\web\sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
我还将其添加到主机文件(Windows):
127.0.0.1 www.plusoneboosters.com.localhost
该项目可以工作,但是所有未安装 symfony 的项目都不再工作 - 正在运行localhost/project/index.php 将重定向到 symfony 项目。
我怀疑这是因为 htaccess 发生的,但不知道要替换什么才能使其工作。
我也尝试添加另一个虚拟主机,但没有成功。
我该如何解决这个问题?
编辑:我想我找到了解决方案。
我在 httpd.conf 中添加了另一个具有不同 IP 的虚拟主机:127.0.0.2,现在似乎工作正常。我不确定这是否是正确的方法......
I am using xampp.
I've set up a project in symfony and added this to apaches httpd.conf:
<VirtualHost 127.0.0.1:80>
ServerName www.plusoneboosters.com.localhost
DocumentRoot "C:\my_xampp\xampp\htdocs\plusoneboosters\web"
DirectoryIndex index.php
<Directory "C:\my_xampp\xampp\htdocs\plusoneboosters\web">
AllowOverride All
Allow from All
</Directory>
Alias /sf "C:\my_xampp\xampp\htdocs\plusoneboosters\lib\vendor\symfony\data\web\sf"
<Directory "C:\my_xampp\xampp\htdocs\plusoneboosters\lib\vendor\symfony\data\web\sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
I also added this to hosts file (Windows):
127.0.0.1 www.plusoneboosters.com.localhost
This project works, but all the projects that are not installed with symfony aren't working anymore - running localhost/project/index.php will redirect to the symfony project.
I suspect this is happening because htaccess, but do not know what to replace in order to make it work.
I also tried adding another virtual host, didn't work.
How can I work around this?
Edit: I think I found a solution.
I added another Virtual host in httpd.conf with a different IP: 127.0.0.2 and it seems to be working fine now. I'm not sure if this is the right way to do it though...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您开始使用虚拟主机时,您需要定义至少两个虚拟主机以保持旧配置正常工作,否则您的 symphony 虚拟主机将成为默认虚拟主机并拦截所有请求。因此,在 symphony vhost 配置之前添加以下行到您的 apache 配置中
如果您有权访问 apache 命令行工具,您可以使用 apachectl -S 来检查 vhost 配置和优先级,它会为您提供所有定义的虚拟主机
Apache 虚拟主机示例
When you start to use virtual hosts you need to define at least two of them to keep your old configuration working otherwise your symphony vhost became the default vhost and intercept all the requests. So add to your apache configuration the following lines BEFORE the symphony vhost configuration
If you have access to apache command line tool you can check the vhost configuration and priority with
apachectl -S
which gives you a report of all the defined virtual hostsApache virtual host examples
我在 Xampp for Symfony 中的设置是:
在主机文件中为我的项目添加条目(例如
127.0.0.1 www.jobeet.com.localhost
)确保conf/extra/httpd-vhosts.conf包含在httpd.conf中(我相信它是默认的:)
请注意,我没有在 httpd.conf 文件中添加任何 VirtualHost 条目本身。这个设置对于我使用最新的 Xampp 来说效果很好,我可以访问 http://localhost/test.html 和 http://www.jobeet.com.localhost 。 > 很好。
My setup in Xampp for Symfony is:
Add entry for my project in hosts file (e.g.
127.0.0.1 www.jobeet.com.localhost
)Make sure conf/extra/httpd-vhosts.conf is included in httpd.conf (I believe it is by default:)
Note that I've not added any VirtualHost entries in the httpd.conf file itself. This setup works fine for me with the latest Xampp, and I can visit both
http://localhost/test.html
andhttp://www.jobeet.com.localhost
just fine.