我在使用nginx
配置Symfony2时遇到问题我像这样安装了symfony2
一切顺利,当我在配置页面上没有错误php composer.phar create-project symfony / framework-standard-edition / var / www / symf
但是当我点击在线配置或Buypass配置我登陆nginx 404时未找到
这是配置文件
upstream phpfcgi {
server 127.0.0.1:9000;
}
server {
listen 80;
server_name localhost;
root /var/www/symf/web;
error_log /var/log/nginx/symfony2.error.log;
access_log /var/log/nginx/symfony2.access.log;
# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ /$1 permanent;
location / {
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass phpfcgi;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
注意:我注意到点击buypass时我登陆的链接就像.... symf / web / app_dev.php / 删除最后/允许我到达页面但得到了错误 点击确定 - >找不到404
我错过了什么?
parameters.yml
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: symfony
database_user: root
database_password: *****
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: fr
secret: ******
debug_toolbar: true
debug_redirects: false
use_assetic_controller: true
答案 0 :(得分:1)
删除该部分
# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ /$1 permanent;
你已经在try file
之后重新编写了这是怎么做的
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
并且确保你重新加载你的nginx服务
答案 1 :(得分:1)
在不知道你的服务器配置的情况下很难提出建议,但这是我的工作配置,它非常好(对于nginx-php-fpm),可能对你有所帮助:
server {
listen 80;
server_name my_site.dev *.my_site.dev;
root /var/www/my_site.dev/public_html/web;
error_log /var/log/nginx/my_site_error.log;
access_log /var/log/nginx/my_site_access.log;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
# Deny all . files
location ~ /\. {
deny all;
}
location ~ ^/(app|app_dev)\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index app.php;
send_timeout 1800;
fastcgi_read_timeout 1800;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
# Statics
location /(bundles|media) {
access_log off;
expires 30d;
# Font files
#if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
# add_header Access-Control-Allow-Origin *;
#}
try_files $uri @rewriteapp;
}
}
答案 2 :(得分:0)
看起来问题出在nginx上,切换到apache2并立即工作
编辑:如果有人知道nginx发生了什么,那么conf文件是错误的吗?我想知道