Install Apache:

yum install httpd
yum install curl-devel httpd-devel

Install Ruby and Ruby and Rails:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable --rails
source ~/.rvm/scripts/rvm
rvm requirements
rvm install ruby
rvm use ruby --default
rvm rubygems current
gem install rails

Install the Passenger:

gem install passenger 
passenger-install-apache2-module

Validate passenger install:

sudo /home/USER/.rvm/gems/ruby-2.2.1/gems/passenger-5.0.26/bin/passenger-config validate-install

You may need to run the following commands:

export ORIG_PATH="$PATH"
 rvmsudo -E /bin/bash
 export PATH="$ORIG_PATH"
 /home/USER/.rvm/gems/ruby-2.2.1/wrappers/ruby /home/USER/.rvm/gems/ruby-2.2.1/gems/passenger-5.0.26/bin/passenger-config validate-install --validate-apache2 --invoked-from-installer

You will get something like this, copy it into /etc/httpd/conf/httpd.conf:

LoadModule passenger_module /home/USER/.rvm/gems/ruby-2.2.1/gems/passenger-5.0.26/buildout/apache2/mod_passenger.so
 <IfModule mod_passenger.c>
 PassengerRoot /home/USER/.rvm/gems/ruby-2.2.1/gems/passenger-5.0.26
 PassengerDefaultRuby /home/USER/.rvm/gems/ruby-2.2.1/wrappers/ruby
 </IfModule>

Install SQLite (If you need it):

yum install sqlite-devel

Change to home directory, and create a rails app:

cd ~
rails new myapp -d postgresql
cd myapp
gem 'therubyracer'
bundle install

Edit /etc/httpd/conf/httpd.conf, add to the bottom (I used the port 3000 for a purpose, you can use the default 80):

<VirtualHost yourdomain:3000>
 ServerName yourdomain.com
 ServerAlias www.yourdomain.com
 DocumentRoot /home/USER/myapp/public
 ServerAdmin webmaster@yourdomain.com
 UserDir enabled USER
</VirtualHost>

Don’t forget to add at the top:

...
Listen 0.0.0.0:3000
...
Listen [::]:3000
...

Then edit /etc/sysconfig/iptables, add these lines:

...
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT
...
-A OUTPUT -p tcp -m tcp --dport 3000 -j ACCEPT

sudo service iptables restart
sudo service httpd restart

Install PostgreSQL:

sudo rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
sudo yum update
sudo yum install postgresql94-server postgresql94-contrib
sudo yum install postgresql postgresql-contrib postgresql-client
sudo yum install postgresql-server-dev-9.4 (for server)
sudo yum install libpq-dev (for client)
sudo yum install postgresql-devel
sudo service postgresql-9.4 initdb
sudo service postgresql-9.4 start
sudo chkconfig postgresql-9.4 on

 

Create a database:

sudo -u postgres psql
\password postgres
CREATE DATABASE testdb ENCODING 'UTF-8';
postgres=# create user testdba with encrypted password 'PASSWORD';
postgres=# grant all privileges on database testdb to testdba;

edit config/database.yml

enter the database name, username and the password.

rake db:migrate
Advertisement