答案 0 :(得分:0)
以下是Symfony2针对最新版本的Apache的vhost示例(为每个站点设置一个):
# /etc/apache2/sites-available/my-app.conf
<VirtualHost *:80>
ServerName my-app.local.fr
DocumentRoot /home/me/Workspace/MySymfonyApp/web
<Directory /home/me/Workspace/MySymfonyApp/web>
Options Includes FollowSymlinks
AllowOverride none
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</Directory>
ErrorLog ${APACHE_LOG_DIR}/my_app_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/my_app_access.log vhost_combined
</VirtualHost>
使用以下命令激活它:
$ sudo a2ensite my-app
重新加载Apache的服务:
$ sudo service apache2 reload
不要忘记激活网址重写(你必须只做一次,而不是所有的虚拟主机)!
$ sudo a2enmod rewrite
$ sudo service apache2 restart