Deploy Ruby on Rails project with Passanger and Ngnix
4 pages
English

Deploy Ruby on Rails project with Passanger and Ngnix

-

Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
4 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

Deploy Ruby on Rails project with Passanger and Ngnix I am assuming that you have installed ruby and rails at your server and have aRuby on railsproject to deploy with Passanger and Ngnix Step 1 -Firstof all we need to add aSudo Userto our system so user can have privilege to access the files. create a user if not exists, in this example I will explain to create a root user tecorb@tecorb-Lenovo-B40-80:~$ adduser root (this will ask few questions like your password etc.) Step 2 -Now we have to add this new user to the sudo group Syntex: tecorb@tecorb-Lenovo-B40-80:~$gpasswd -a root sudo Step 3 -Now we need to install Passenger and Nginx First of all we will install a PGP (Pretty Good Privacy) key: tecorb@tecorb-Lenovo-B40-80:~$sudo apt-key adv --keyserver keyserver.ubuntu.com --recvkeys 561F9B9CAC40B2F7 Now we have to create an APT (Advanced Packaging Tool) source file tecorb@tecorb-Lenovo-B40-80:~$sudo vim /etc/apt/sources.list.d/passenger.list And insert the following line in the file: deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main PressESCthen:wqand hitenter, Now our file has been saved throughvi editor TecOrb Technologies Now we need to change the owner and permissions for thispassenger.listfile: tecorb@tecorb-Lenovo-B40-80:~$sudo chown root: /etc/apt/sources.list.d/passenger.list tecorb@tecorb-Lenovo-B40-80:~$sudo chmod 600 /etc/apt/sources.list.d/passenger.

Informations

Publié par
Publié le 17 avril 2017
Nombre de lectures 1
Langue English

Extrait

Deploy Ruby on Rails project with Passanger and Ngnix
I am assuming that you have installed ruby and rails at your server and have aRuby on railsproject to deploy with Passanger and Ngnix
Step 1 -Firstof all we need to add aSudo Userto our system so user can have privilege to access the files.
create a user if not exists, in this example I will explain to create a root user
tecorb@tecorb-Lenovo-B40-80:~$adduser root (this will ask few questions like your password etc.)
Step 2 -Now we have to add this new user to the sudo group
Syntex: tecorb@tecorb-Lenovo-B40-80:~$gpasswd -a root sudo
Step 3 -Now we need to install Passenger and Nginx
First of all we will install a PGP (Pretty Good Privacy) key:
tecorb@tecorb-Lenovo-B40-80:~$sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
Now we have to create an APT (Advanced Packaging Tool) source file
tecorb@tecorb-Lenovo-B40-80:~$sudo vim /etc/apt/sources.list.d/passenger.list
And insert the following line in the file:
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main
PressESCthen:wqand hitenter, Now our file has been saved throughvi editor
TecOrb Technologies
Now we need to change the owner and permissions for thispassenger.listfile:
tecorb@tecorb-Lenovo-B40-80:~$sudo chown root: /etc/apt/sources.list.d/passenger.list tecorb@tecorb-Lenovo-B40-80:~$sudo chmod 600 /etc/apt/sources.list.d/passenger.list
Now we have to update our APT cache:
tecorb@tecorb-Lenovo-B40-80:~$sudo apt-get update
And finally, we will install Passenger with Nginx:
tecorb@tecorb-Lenovo-B40-80:~$sudo apt-get install nginx-extras passenger
Step 4-In this step we will open the Nginx configuration file for some changes:
tecorb@tecorb-Lenovo-B40-80:~$sudo vim /etc/nginx/nginx.conf
now file will be open invi editer,Uncomment given line, These lines will look like this:
# passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; # passenger_ruby /usr/bin/ruby;
uncomment these lines and update the path mentioned in thepassenger_rubyline and add default user :
passenger_default_user root; passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; passenger_ruby /usr/local/rvm/gems/ruby-2.3.0/wrappers/ruby;
Note if you are unable to get what is your path to ruby then follow these steps:
TecOrb Technologies
tecorb@tecorb-Lenovo-B40-80:~$which passenger-config this will return a path like:/usr/bin/passenger-config
If you are on RVM and use Ruby 2.2.1 (version can be whatever you are using)
tecorb@tecorb-Lenovo-B40-80:~$rvm use 2.2.1
Now finally, we will invoke passenger-config with its full path, passing --ruby-command as parameter like:
tecorb@tecorb-Lenovo-B40-80:~$/usr/bin/passenger-config --ruby-command
This will show you something like:
To use in Apache: PassengerRuby /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby  To use in Nginx : passenger_ruby /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby  To use with Standalone: /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby /opt/passenger/bin/passenger start
From here you will get path for your passenger_ruby (Nginx). This path will use at passenger_ruby in nginx.conf
Now finally we will save our file and exit by PressESCthen type:wqand hit enter.
Step 5-Now we have allmost done, we need to disable the default Nginx configuration at Nginx config file:
tecorb@tecorb-Lenovo-B40-80:~$sudo vim /etc/nginx/sites-available/default
Findout these lines and comment them:
# listen 80 default_server; # listen [::]:80 default_server ipv6only=on;
Save this config file, PressESCthen type:wqand hit enter.
Step 6-Now we will create an Nginx configuration file for our application (like our app name is tecorbapp):
tecorb@tecorb-Lenovo-B40-80:~$sudo vim /etc/nginx/sites-available/tecorbapp
Add the following server block into this file:
server {  listen 80 default_server;  server_name tecorbdomain.com www.tecorbdomain.com;  passenger_enabled on;  passenger_app_env development;  root /home/rails/tecorbapp/public; }
TecOrb Technologies
In this file we enable listening on port 80, set our domain, enable Passenger, set the application environment here we have used development environment and set the root to the public directory of our ruby on rails project. If you don't want to add your domain to the application, you can skip the server_name line from this file, or if you want to use any IP address you can replace tecorbdomain.com www.tecorbdomain.comwith your ip address.
Now we will save this config file, PressESCthen type:wqand hit enter.
Step 7-Now finally we will create a symlink this file:
tecorb@tecorb-Lenovo-B40-80:~$sudo ln -s /etc/nginx/sites-available/tecorbapp /etc/nginx/sites-enabled/tecorbapp
and Restart our Nginx:
tecorb@tecorb-Lenovo-B40-80:~$sudo nginx -s reload
Now our application should be accessible from our domain, go to your browser and hit the domain.
Good Luck!
TecOrb Technologies
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents