Reputation: 6725
I have set up a Symphony 3 site on my local computer that works. I then uploaded it to my server which is a Debian Jessie server with Nginx 1.8 set up on it with PHP 7 .
When i try and access the site i get the following error
api.server.com is currently unable to handle this request. HTTP ERROR 500
When i look at the error logs i get the following:
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"
my nginx server configuration
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;
}
Can anyone please offer some help as to what I am doing wrong?
Upvotes: 0
Views: 129
Reputation: 7764
Looks like you need to setup permissions correctly:
Do something like this:
$ 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
From the Symfony3 install directory. The httpd user needs permission to the var directory. The user might be 'nginx' in your case, I'm not certain.
Upvotes: 1