Skip to content

Instantly share code, notes, and snippets.

@vincent178
Last active November 5, 2018 19:17
Show Gist options
  • Save vincent178/9595359 to your computer and use it in GitHub Desktop.
Save vincent178/9595359 to your computer and use it in GitHub Desktop.
CentOS install Ruby Rails Nginx and Passenger (tested on CentOS 6.3)

Install Sudo

Update yum

$ yum update

Install Sudo

$ yum install sudo

Create Account

Create Account for Application

$ useradd -m -s /bin/bash deploy

Add write permission to sudoers

$ chmod u+w /etc/sudoers

Modify file to add deploy group

## Allows people in group wheel to run all commands
# %wheel	ALL=(ALL)	ALL
%deploy ALL=(ALL) ALL

Remove write permission to sudoers

$ chmod u-w /etc/sudoers

Set the Password for User

$ passwd deploy

Then Exit and Login use Deploy

Install RVM and Ruby

Install curl

$ sudo yum install curl

Install RVM

$ \curl -sSL https://get.rvm.io | bash

Exit and Relogin with deploy to initialize RVM

$ type rvm | head -1 

It should show rvm is a function

Install Requirements and Ruby 1.9.3

$ sudo yum install libyaml-devel
$ rvm use --install --default 1.9.3
$ ruby -v

It should show ruby 1.9.3p545

Install Bundler

$ gem install bundler

Install Nginx

$ sudo yum install nginx

Database

Install sqlite3, redis

$ sudo yum install sqlite sqlite-devel
$ sudo yum install redis

Upload your files

Install git

$ sudo yum install git

Generate SSH keygen

$ ssh-keygen
$ cd ~/.ssh

Copy id_rsa.pub to the gitsum deploy

Create site folder

$ sudo mkdir -p /var/www/
$ sudo chown deploy:deploy /var/www/

Clone the project

$ cd /var/www/
/var/www/ $ git clone [email protected]:APAC-Local/school_title_normalization_api.git

Run Application

Install gems

$ cd /var/www/school_title_normalization_api/
$ bundle

Copy nginx.conf to /etc/nginx/

$ sudo cp config/nginx.conf /etc/nginx/

Start Nginx

$ sudo service nginx start

Start Redis

$ redis-server config/redis.conf

Start Application

$ rake index_database
$ ruby start_server.rb

Restart Nginx

$ sudo service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment