NOTE: This sequence has been successfully applied on an Ubuntu 14.04 server machine
NOTE: Before anything, install the add-apt-repository
command if needed
apt-get install python-software-properties software-properties-common
see http://wiki.nginx.org/Install and http://stackoverflow.com/questions/7214474/how-to-keep-up-with-the-latest-versions-of-nodejs-in-ubuntu-ppa-compiling
Add ppa repositories, update apt and install
add-apt-repository ppa:nginx/stable
add-apt-repository ppa:chris-lea/node.js
apt-get update
apt-get install nginx nodejs
Check versions
nginx -v
node -v
see http://wiki.nginx.org/Configuration and for "from-zero" introduction see http://blog.martinfjordvald.com/2010/07/nginx-primer/
Multiple site configs are stored on sites-available
, enabled on sites-enabled
.
cd /etc/nginx
For better managment, use nginx_modsite
script
see http://serverfault.com/questions/424452/nginx-enable-site-command
vim /usr/bin/nginx_modsite
:set paste
# paste...
:wq
chmod +x /usr/bin/nginx_modsite
Now we can list, enable, and disable with nginx_modsite
nginx_modsite -l
nginx_modsite -e sitename
nginx_modsite -d sitename
Single site, setup on nginx.conf
directly
vim nginx.conf
# delete everything & edit...
# or paste from this gist & edit...
:set paste
:%s/example/sitename/gc
# y, y, y, y ...
:wq
NOTE: Ensure to edit the conf to fit your app requeriments
Test config and restart nginx
nginx -t
service nginx restart
Maybe you will need git or other to get the source code...
apt-get install git
Get the app source code
cd /home
git clone https://github.com/laconbass/{reponame}.git
Install dependencies, test it works, etc...
git submodule init && git submodule update
npm install
npm start
Install forever
npm install -g forever
Create an upstart script for the application
see http://serverfault.com/questions/506999/simple-upstart-script-for-nodejs-forever-on-ubuntu
vim /etc/init/example.com.conf
:set paste
# paste from this gist...
:%s/example.com/sitename.domain/gc
# change the routes to the needed ones
:wq
service example.com start
Check it's running ok
forever list
cat forever.log
cat err.log
cat out.log