我的nginx配置有问题。
在大多数网页和Google搜索条目中,我发现了“nginx和symfony2”或“子目录中的nginx和symfony2”之类的内容。 但是我没有找到关于这种配置的一些事情:
server
{
listen 80;
listen [::]:80 default_server ipv6only=on;
root /srv/www;
index index.php index.html index.htm app.php app_dev.php;
try_files $uri $uri/ index.php @rewriteapp /index.php;
server_name localhost;
location ~ ^\/symfony2
{
#rewrite ^\/symfony2(.*)$ /symfony2/web$1 last;
#root /srv/www/symfony2/web;
alias /srv/www/symfony2/web;
}
location @rewriteapp
{
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ \.php(/|$)
{
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
提前感谢每个提示!
答案 0 :(得分:0)
此配置应有帮助。
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
root /srv/www;
index index.php index.html index.htm app.php app_dev.php;
server_name localhost;
location / {
try_files $uri $uri/ /app.php /index.php;
location ~ .*\.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
location /symfony2 {
alias /srv/www/symfony2/web;
location ~ .*\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /symfony2(?<path>.*)$ {
root /srv/www/symfony2/web;
try_files $path $path/ /app.php$path;
}
}
}