I deleted my NGINX log because it was very large, thinking that NGINX would automatically create a new one in its place. It didn't, and now I don't have logs. The file was previously located at /opt/nginx/logs/error.log
. I tried creating a new file with the same permissions in the same location but it doesn't appear to have helped. I'm running nginx/1.4.7 on an ubuntu 12.10 server.
How do I get my logging back?
I've tried sudo service nginx restart
and it says nginx: unrecognized service
. I think this might be because I'm using NGINX with Phusion Passenger to serve a rails app and Passenger has changed a few things. For example, NGINX lives in /opt/nginx
instead of init.d
.
Passenger author here.
Restarting Nginx would actually make the log file come back. It's just that you're not using the right method to restart Nginx, because your Nginx install was installed from source.
Init scripts, e.g. /etc/init.d/nginx
and service nginx restart
, are not provided by the default Nginx source code. Init scripts are actually extensions provided by the operating system's Nginx package. If you install Nginx from source, then you can't use init scripts to control Nginx anymore. Instead, you will use more generic operating system primitives to control Nginx, such as PID files and signals. Learn more at the Passenger documentation.
Restarting Nginx is to be done by sending signals to it and by starting it again through the Nginx command. For example:
sudo kill $(cat /opt/nginx/logs/nginx.pid)
sudo /opt/nginx/sbin/nginx
To learn more about restarting an Nginx that was installed from source, read this part of the Passenger documentation.