I recently moved my CentOS 7 machine from Apache to nginx, and I am still working out the differences. One issue I have noticed for only one of my server blocks is that access and error log files are not actually being logged to, making it difficult to troubleshoot potential issues.
The server block for my site looks like the following:
server {
listen 80;
server_name example.com;
root /var/www/example.com/public_html;
index index.php;
access_log /var/www/example.com/logs/example.com_access.log;
error_log /var/www/example.com/logs/example.com_error.log error;
location / {
index index.php index.html;
}
location /reports {
autoindex on;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 404 /var/www/html/404.html;
error_page 500 502 503 504 /var/www/html/50x.html;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location /robots.txt {
#access_log off;
#log_not_found off;
}
location ~ /\.ht {
deny all;
}
}
I am unsure why the logs would not be kept. I compared file permissions across my server blocks, and they all share the same permissions.
-rw-r--r--. 1 nginx root 0 Nov 7 02:54 example.com_access.log
-rw-r--r--. 1 nginx root 0 Nov 7 02:54 example.com_error.log
What could be the problem with why logs are not being stored?