Follow Phusion Passenger URL for Ubuntu setup https://www.phusionpassenger.com/library/install/nginx/install/oss/trusty/ ( If in future above URL is not present then visit to Phusion Passenger site to select Ubuntu OS and futher instaltion steps.)
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
- sudo apt-get install -y apt-transport-https ca-certificates
- sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main > /etc/apt/sources.list.d/passenger.list'
- sudo apt-get update
- sudo apt-get install -y nginx-extras passenger
- Add passenger_nodejs in staring of http block. Like below
passenger_nodejs /home/ubuntu/.nvm/versions/v0.12.5/bin/node;
In passenger_nodejs you need to pass output of "which node" command.
- Uncomment below line
include /etc/nginx/passenger.conf;
- Remove below lines:-
root /usr/share/nginx/html;
index index.html index.htm index.nginx-debian.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
- Add below lines inside first server block
server_name localhost; # You can pass your domain URL.
passenger_app_root /home/node_demo_app; # full path to node app directory
passenger_enabled on;
passenger_app_type node;
passenger_startup_file server.js; # main file name which start http server
root /home/node_demo_app/public; # full path to node app till public directory
All setup done. Restart your nginx sudo service nginx restart and hit server IP("server_name" value).
Thanks!