1👍
init.d is not the right supervisor to use on Ubuntu anymore, you should use Upstart. Put this in /etc/init/nginx.conf and you will be able to start/stop it with sudo start nginx
and sudo stop nginx
:
description "nginx http daemon"
author "George Shammas"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/usr/local/nginx/sbin/nginx -c /my/project/config/nginx.conf
env PID=/usr/local/nginx/logs/nginx.pid
expect fork
respawn
respawn limit 10 5
pre-start script
$DAEMON -t
if [ $? -ne 0 ]
then exit $?
fi
end script
exec $DAEMON
Source:stackexchange.com