This step-by-step article lists the steps required to install and run a node.js application on a clean Ubuntu 14.04 server.
nginx (engine x) is an HTTP and reverse proxy server, as well as a mail proxy server. We are going to use it to allow multiple node.js applications to run on the same physical server.
On the Windows host computer I installed node.js from here.
I've got an error:
Error: ENOENT, stat 'C:\Users\%USER%\AppData\Roaming\npm'
npm so I did a
npm was happy. I installed express globally using
npm install -g express npm install -g express-generator
.gitignore can be:
.bin node_modules/* *.user
node.js in Server
Create a new user to run node tasks.
sudo adduser noderunner
but don't switch to it, yet. Install npm and node:
sudo apt-get install npm nodejs
/etc/ssh/sshd_config we may want to allow access to certain users.
Add a line like:
AllowUsers git noderunner $YOUR_USER_NAME su noderunner mkdir .ssh && chmod 700 .ssh touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys sudo chmod -R 0750 /home/git echo "ssh-rsa ... rsa-key-20141025" >> ~/.ssh/authorized_keys exit
Pom to the Rescue
Pod seems like exactly the application for us.
On the server
sudo npm install -g pod
The switch to
noderunner user and follow along:
We need a directory for pod stuff, so I called it
To create a new application:
pod create myapp
In local computer:
git remote add deploy noderunner@$IP_OR_NAME:~/podstuff/repos/myapp.git git push deploy master
To check the status use either
$IP_OR_NAME:19999 using a web browser after
has been issued. The credentials are
admin/admin and can be changed in
~/.podrc. See an example config file with all options
sudo apt-get install nginx sudo service nginx start cd /etc/nginx/sites-available nano myapp
Fill in the content:
Enable the site:
cd ../sites-enabled sudo ln -s /etc/nginx/sites-available/myapp myapp sudo rm default
And restart nginx:
sudo service nginx restart