Debian Jessie Nginx 1.8.0 Symfony 3 返回 500 响应
Debian Jessie Nginx 1.8.0 Symfony 3 returning 500 response
我已经在我的本地计算机上设置了一个可以运行的 Symphony 3 站点。然后我将它上传到我的服务器,这是一个 Debian Jessie 服务器,上面安装了 Nginx 1.8 PHP 7 .
当我尝试访问网站时出现以下错误
api.server.com is currently unable to handle this request.
HTTP ERROR 500
当我查看错误日志时,我得到以下信息:
2016/06/26 20:45:03 [error] 28099#0: *1 FastCGI sent in stderr: "PHP
message: PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/aqua_note/var/logs/prod.log" could not be opened: failed to open stream: Permission denied in /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:97
Stack trace:
#0 /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php(112): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\FingersCrossedHandler->handle(Array)
#3 /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Logger.php(643): Monolog\Logger->addRecord(500, 'Uncaught PHP Ex...', Array)
#4 /var/www/aqua_note/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php(89): Monolog\Logger->critical('Uncaught PHP Ex...', Array)
#5" while reading response header from upstream, client: 108.46.158.41, server: api.servername.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "api.servername.com"
我的 nginx 服务器配置
server {
server_name api.servername.com;
root /var/www/aqua_note/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
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;
}
# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
#return 404;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
任何人都可以就我做错了什么提供一些帮助吗?
看来您需要正确设置权限:
做这样的事情:
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
来自 Symfony3 安装目录。 httpd 用户需要对 var 目录的权限。在你的情况下,用户可能是 'nginx',我不确定。
我已经在我的本地计算机上设置了一个可以运行的 Symphony 3 站点。然后我将它上传到我的服务器,这是一个 Debian Jessie 服务器,上面安装了 Nginx 1.8 PHP 7 .
当我尝试访问网站时出现以下错误
api.server.com is currently unable to handle this request. HTTP ERROR 500
当我查看错误日志时,我得到以下信息:
2016/06/26 20:45:03 [error] 28099#0: *1 FastCGI sent in stderr: "PHP
message: PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/aqua_note/var/logs/prod.log" could not be opened: failed to open stream: Permission denied in /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:97
Stack trace:
#0 /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php(112): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\FingersCrossedHandler->handle(Array)
#3 /var/www/aqua_note/vendor/monolog/monolog/src/Monolog/Logger.php(643): Monolog\Logger->addRecord(500, 'Uncaught PHP Ex...', Array)
#4 /var/www/aqua_note/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php(89): Monolog\Logger->critical('Uncaught PHP Ex...', Array)
#5" while reading response header from upstream, client: 108.46.158.41, server: api.servername.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "api.servername.com"
我的 nginx 服务器配置
server {
server_name api.servername.com;
root /var/www/aqua_note/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
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;
}
# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
#return 404;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
任何人都可以就我做错了什么提供一些帮助吗?
看来您需要正确设置权限:
做这样的事情:
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var
来自 Symfony3 安装目录。 httpd 用户需要对 var 目录的权限。在你的情况下,用户可能是 'nginx',我不确定。