[英]Symfony2 + Nginx 404 not found
我在用nginx配置Symfony2時遇到問題
我這樣安裝了symfony2
php composer.phar創建項目symfony / framework-standard-edition / var / www / symf
一切順利,當我在配置頁面上時沒有錯誤
但是當我單擊“在線配置”或“購買通過”配置時,我無法登錄到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;
}
}
注意:我發現單擊“購買通行證”時發現我登陸了類似.... 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
刪除該部分
# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ /$1 permanent;
在try file
之后,您已經在此處重新try file
,應該怎么做
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
並且確保您重新加載了Nginx服務
在不知道服務器配置的情況下很難提出建議,但是這是我的工作配置,它工作得很好(對於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;
}
}
看起來問題出在nginx上,切換到apache2並立即運行
編輯:如果有人知道nginx發生了什么,conf文件是否錯誤? 我想知道
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.