1. Go to /etc/init.d
and run sudo vim nginx-passenger.sh
, then paste in this code:
#!/bin/bash # this script starts the nginx process attached to passenger sudo /opt/nginx/sbin/nginx
save and exit.
2. Make the file executable by typing sudo chmod +x /etc/init.d/nginx-passenger.sh
You can test to see if the script works by typing sudo /etc/init.d/nginx-passenger.sh
this will run all the code in the script.
3. Go to /etc/init.d
directory. Then run sudo update-rc.d nginx-passenger.sh defaults
Once all of this is in place, reboot your server and ngnix should now be automatically spawned on startup