Это моя конфигурация:
server {
server_name domain.com;
root /var/www/domain.com/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/app.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
error_log /var/log/nginx/domain.com.error.log;
access_log /var/log/nginx/domain.com.access.log;
}
Сайт электронной почты работает, domain.com/
, но всякий раз, когда я открываю любой другой маршрут, например domain.com/test/
я получаю 500 внутренних ошибок сервера.
Кроме того, когда я открываю среду dev, например domain.com/app_dev.php/test/
я получаю сообщение об ошибке, что я не могу получить доступ app_dev.php
файлу app_dev.php
.
Что не так?
Попробуй это:
server {
listen *:80;
server_name time.dev www.time.dev;
client_max_body_size 1m;
root /var/www/time/web;
index app_dev.php;
access_log /var/log/nginx/xxx_time.access.log;
error_log /var/log/nginx/xxx_time.error.log;
location ~ \.php$ {
root /var/www/time/web;
fastcgi_index app_dev.php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
try_files $uri $uri/ /app_dev.php$is_args$args;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param APP_ENV dev;
}
location / {
root /var/www/time/web;
try_files $uri $uri/ /app_dev.php$is_args$args;
autoindex off;
index index.html index.htm index.php;
}
sendfile off;
}
Он скопировал мою машину-бродягу.
routing.yml
? Что касаетсяapp_dev.php
- доступ к этому файлу закрыт из не localhost по соображениям безопасности, вы можете посмотреть код самостоятельно и даже снять защиту, если вам нужно./var/log/nginx/domain.com.error.log
и/var/www/domain.com/app/logs/prod.log
для получения дополнительной информации.