设置symfony项目并更改主机文件后,非symfony项目将不再是';我不再在apache上工作了?
我正在使用xampp 我在symfony中设置了一个项目,并将其添加到apaches httpd.conf中:设置symfony项目并更改主机文件后,非symfony项目将不再是';我不再在apache上工作了?,apache,symfony1,dns,Apache,Symfony1,Dns,我正在使用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_xa
<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>
这个项目可以工作,但是所有没有安装symfony的项目都不再工作了-运行localhost/project/index.php将重定向到symfony项目
我怀疑发生这种情况是因为htaccess,但不知道要更换什么才能使其正常工作
我还尝试添加另一个虚拟主机,但没有成功
我怎样才能解决这个问题
编辑:我想我找到了解决办法
我在httpd.conf中添加了另一个具有不同IP的虚拟主机:127.0.0.2,现在它似乎工作正常。我不确定这是否是正确的方法,但是…当您开始使用虚拟主机时,您需要定义至少两个虚拟主机以保持旧配置正常工作,否则symphony vhost将成为默认vhost并拦截所有请求。因此,在symphony vhost配置之前,在apache配置中添加以下行
# this allows vhost based on hostname and NOT on ip only
NameVirtualHost *
<VirtualHost _default_>
ServerName localhost
DocumentRoot "your old document root"
DirectoryIndex index.php
<Directory "your old root document root">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName www.plusoneboosters.com.localhost
...
</VirtualHost>
#这允许vhost基于主机名,而不仅仅基于ip
名称虚拟主机*
服务器名本地主机
DocumentRoot“您的旧文档根”
DirectoryIndex.php
允许超越所有
通融
服务器名www.plusoneboosters.com.localhost
...
如果您可以访问apache命令行工具,则可以使用apachectl-S
检查vhost配置和优先级,该工具将为您提供所有已定义虚拟主机的报告
我在Xampp中为Symfony设置的设置是:
- 在主机文件中为我的项目添加条目(例如
)127.0.0.1 www.jobeet.com.localhost
- 确保httpd.conf中包含conf/extra/httpd-vhosts.conf(我认为默认情况下是:)
- 在conf/extra/httpd-vhosts.conf中,添加(取消注释并编辑)默认主机的条目:
- 然后,在下面添加Symfony项目的条目:
注意,我没有在httpd.conf文件中添加任何VirtualHost条目。使用最新的Xampp,这个设置对我来说很好,我可以访问这两个
http://localhost/test.html
和http://www.jobeet.com.localhost
很好。第二个虚拟主机(用于symfony项目)必须具有不同的IP,对吗?因为当我保持不变时,它就不工作了。@Tool:它可以在同一个IP上(我所有的vhost都在::1上)。@Tool您应该定义NameVirtualHost
apache指令来使用同一个IP。我更新了我的答案以反映这一点,并提供了一个指向apache配置示例的链接。在xampp apache配置目录中是否有一个带有“httpd vhosts.conf”文件的“额外”目录?因为这是我添加我的,根据我的记忆,可能是在取消默认条目的注释之后。也许在httpd.conf文件中添加它会让事情变得混乱?
# this allows vhost based on hostname and NOT on ip only
NameVirtualHost *
<VirtualHost _default_>
ServerName localhost
DocumentRoot "your old document root"
DirectoryIndex index.php
<Directory "your old root document root">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName www.plusoneboosters.com.localhost
...
</VirtualHost>
# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"
ServerName localhost
DocumentRoot "C:/Matt/xampp/htdocs/"
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" combined
ServerName www.jobeet.com.localhost
DocumentRoot "C:/Matt/xampp/htdocs/jobeet/web"
DirectoryIndex index.php
AllowOverride All
Allow from All
Alias /sf "C:/Matt/xampp/htdocs/jobeet/lib/vendor/symfony/data/web/sf"
AllowOverride All
Allow from All