虚拟主机上的Symfony 2 [英] Symfony 2 on virtual hosts
问题描述
我在这里遇到Symfony 2的问题.我想在Windows Vista PC上安装虚拟主机,因此可以像这样myapp.local.com
来访问我的Symfony应用程序.
我尝试过的:
I have a problem here with Symfony 2. I want to have virtual host on Windows Vista PC, so I can access my Symfony application like this myapp.local.com
.
What I have tried:
-
我将这些行添加到主机文件
I added these lines to hosts file
127.0.0.1 local.com
127.0.0.1 myapp.local.com
这些我添加到了Apache httpd-vhosts.conf
These I added to apache httpd-vhosts.conf
< VirtualHost myapp.local.com:80 >
DocumentRoot "d:/data/www/myapp/web"
ServerName myapp.local.com
Alias /sf /$sf_symfony_data_dir/web/sf
< Directory "/$sf_symfony_data_dir/web/sf" >
AllowOverride All
Allow from All
< /Directory >
< Directory "d:/data/www/myapp/web" >
AllowOverride All
Allow from All
< /Directory >
< /VirtualHost >
,但是当我在浏览器中编写myapp.local.com
时,它会带来www
目录的索引.我在做什么错了?
but when I write myapp.local.com
in my browser, it brings the index of my www
directory. What am I doing wrong?
推荐答案
您正在使用为Symfony 1建议的虚拟主机配置.
You are using the virtualhost configuration proposed for Symfony 1.
我在Linux下用于Symfony2的虚拟主机看起来像这样:
My virtualhost for Symfony2 under linux looks like this:
<VirtualHost *:80>
ServerName www.domain.com.localhost
ServerAlias domain.com.localhost
ServerAdmin webmaster@localhost
DocumentRoot /home/user/www/project/web
<Directory /home/user/www/project/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
尝试此操作(适应Windows中的配置),重新启动Apache,然后再次尝试访问URL.
Try this (adapted to your config in windows), restart Apache, and try accessing the URL again.
您可以在此食谱条目上找到有关Symfony2虚拟主机的更多信息.
You will find more informations on Symfony2 virtual hosts on this cookbook entry.
这篇关于虚拟主机上的Symfony 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!