Q:

How to know what causes nginx to stop?

My Website was down because nginx service stopped. sudo service nginx restart was enough to bring it back. 
To make sure this will not happen again, I want to know what causess nginx daemon to stop. 
Are their any dedicated logs I can check to make such a diagnosis ?  

A:

You can check the system log (/var/log/messages on RH-based systems and /var/log/syslog on Debian-based systems). You can also check the nginx error log for anything relevant. If it doesn't capture what you're after you may try to increase the log level via the error_log directive and wait for it to happen again. For example:
error_log  /var/log/nginx/error.log debug;

Note that debug level will produce a lot of output. So be prepared for that. More information on the error_log directive here.

