2015/02/04

Ruby on rails on Centos 7 with apache2 and passenger

Before doing following steps, please turn off selinux

vim /etc/selinux/config
find this line SELINUX=enforcing, and change to SELINUX=disabled
and reboot

Install LAMP

yum install httpd mariadb-server mariadb php php-mbstring php-mysql php-gd mysql mysql-develStart and enable phpMyAdmin
sudo yum install epel-release
sudo yum install phpmyadmin

Install rvm

gpg –keyserver hkp://keys.gnupg.net –recv-keys D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable

Use rvm install ruby

rvm install ruby
rvm –default use 2.2.0

Install rails and bundle

gem install rails
gem install bundle

Install passenger and dependency

gem install passenger
sudo yum install libcurl-devel
sudo yum install httpd-devel
sudo yum install apr-devel
sudo yum install apr-util-devel

Install passenger with apache2

passenger-install-apache2-module
Add following lines in /etc/http/conf/httpd.conf or create file /etc/httpd/conf.d/passenger.conf

LoadModule passenger_module /home/apple/.rvm/gems/ruby-2.2.0/gems/passenger-4.0.58/buildout/apache2/mod_passenger.so

<IfModule mod_passenger.c>

PassengerRoot /home/apple/.rvm/gems/ruby-2.2.0/gems/passenger-4.0.58

PassengerDefaultRuby /home/apple/.rvm/gems/ruby-2.2.0/wrappers/ruby

</IfModule>

Create new ror project

cd /var/www/html
rails new ror -d mysql
configure /var/www/html/ror/config/database.yml file

Add following lines to /etc/httpd/conf/httpd.conf

RailsEnv development
<VirtualHost *:80>
      ServerName localhost
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /var/www/html/ror/public
      <Directory /var/www/html/ror/public>
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
         # Uncomment this if you're on Apache >= 2.4:
         Require all granted
      </Directory>
</VirtualHost>

sudo systemctl restart httpd.service

Trouble shooting phpmyadmin not show correctly

add lines after alias

alias /phpmyadmin /usr/share/phpMyAdmin
alias /phpMyAdmin /usr/share/phpMyAdmin

<Location /phpmyadmin>
   PassengerEnabled off
</Location>
<Location /phpMyAdmin>
   PassengerEnabled off
</Location>

2 則留言:

  1. Nice blog keep updating your blog and i am waiting for your next update also keep update the blogger.Ruby on Rails Online Course

    回覆刪除
  2. Your blog post is amazing and full of knowledge, thanks for publishing your post. I want to tell you everyone that I also provide a ruby on rails online course

    回覆刪除