Phusion Passenger is an application server which can be integrated into web server like Apache web servers and allows to serve Ruby/Rails applications via the web server. It’s a good option to deploy Ruby on Rails application on productions systems. This article will help you to deploy Ruby application with Apache on CentOS, Red Hat and Fedora systems. You can use this tutorial for staging as well as production deployments.
First of all, we assume you already have Ruby installed on your system. If you do not have Ruby installed on your system, Use one of below URL to install it as per your application requirements.
Step 1 – Install Prerequisites
First of all, enable epel yum repository and update packages on your system.
$ sudo yum install -y epel-release yum-utils $ sudo yum-config-manager --enable epel $ sudo yum clean all && sudo yum update -y
Step 2 – Install Apache Passenger Module
Now install rails and passenger gem on your system. Execute below commands to install both gem command.
$ sudo yum install -y pygpgme curl $ sudo curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
Now install the passenger for the Apache on your system using the following command.
$ sudo yum-config-manager --enable cr && sudo yum install -y mod_passenge
Step 3 – Validate Apache Passenger Module
The default passenger configuration file for Apache create at /etc/httpd/conf.d/passenger.conf. You can edit this file and check the settings like below.
$ vim /etc/httpd/conf.d/passenger.conf
The default PassengerRuby option is set to /usr/bin/ruby. I have changed it to our custom ruby installed with rvm like below screenshot.
Now, validate the passenger installation and configuration with the following command.
$sudo /usr/bin/passenger-config validate-install
Step 4 – Configure Apache VirtualHost
Let’s configure the VirtualHost in Apache configuration with the domain name. The example virtual host configuration will look like below.
<VirtualHost *:80> ServerName
example.com # Path to Ruby Application's 'public' directoryDocumentRoot /path-to-your-app/public <Directory /path-to-your-app/public> Allow from all Options -MultiViews # Uncomment this if you're on Apache > 2.4: #Require all granted </Directory> </VirtualHost>
Step 5 – Restart Apache Service
After adding above lines in Apache configuration, restart Apache service using the following command.
$ sudo systemctl restart httpd.service
I followed your instructions to configure the Ruby on Rails Application with Apache using Phusion Passenger. Your instructions looks to be very specific to the point.
However, I encountered some errors while restarting the httpd services. Running the command # passenger-install-apache2-module asked me to add the following lines to the httpd.conf file.
” LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.0/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
I added the above lines into the httpd.conf files’ module session(before the ).
I then issued the command to restart the httpd and am getting the following error message. I am new to Ruby on Rail and also Linux. Trying to setup an application with Ruby on Rails. Could you please advise me what is wrong here?
“[[email protected] ~]# service httpd restart
Stopping httpd: [FAILED]
Starting httpd: httpd: Syntax error on line 969 of /etc/httpd/conf/httpd.conf: Cannot load /usr/local/rvm/gems/ruby-2.1.0/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so into server: /usr/local/rvm/gems/ruby-2.1.0/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so: failed to map segment from shared object: Permission denied
Looking forward for your answer.
Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You definitely know what youre talking about, why throw away your intelligence on just posting videos to your weblog when you could be giving us something enlightening to read?