Tutorials

How to install Nginx with Passenger 5.0 on Fedora.

In this guide I will show how you can install Passenger compiled with Nginx on Fedora.
Please be aware I am not a Passenger expert and this guide is based on what I normally do.

There are two version of Passenger an open-source version that I will use for this guide and a paid Enterprise version if you are going to use Passenger in your company I would advise having a look at their website for the Enterprise version:
https://www.phusionpassenger.com/

For this guide I used the following:
Server (1x cpu, 2gb ram)
Fedora
Passenger + Nginx
This guide should also work on RHEL, CentOS and OracleLinux but you might need to change some directory locations or use slightly different commands.

Step 1: Add the Ulyaoth repository
Have a look on my forum for the latest rpm and instructions:
https://community.ulyaoth.com/resources/categories/repository.1/

Step 2: install the required packages
$ sudo dnf install -y ulyaoth-nginx ulyaoth-nginx-module-passenger5 openssl ruby rubygem-rails

If you have selinux you should also install:
$ sudo dnf install -y ulyaoth-nginx-module-passenger5-selinux

Step 3: Create the following directories

$ sudo mkdir -p /usr/share/nginx/ulyaoth/public
$ sudo mkdir -p /var/log/nginx/passenger.ulyaoth.net

Step 4: Fix your Firewall to allow port 80.
$ firewall-cmd --permanent --zone=FedoraServer --add-service=http

Step 5: Restart firewalld.
$ sudo systemctl restart firewalld.service

Step 6: Put nginx-passenger on autostart when the server is rebooted.
$ sudo systemctl enable nginx.service

Step 7: Download the nginx vhost and symbolic link it.

$ sudo wget https://raw.githubusercontent.com/sbagmeijer/ulyaoth/master/guides/passenger/nginx/passenger.ulyaoth.net.conf -O /etc/nginx/sites-available/passenger.ulyaoth.net.conf
$ sudo ln -s /etc/nginx/sites-available/passenger.ulyaoth.net.conf /etc/nginx/sites-enabled/passenger.ulyaoth.net.conf

Step 8: Open the vhost and fix the server name.
$ sudo vi /etc/nginx/sites-available/passenger.ulyaoth.net.conf
Now change the line with “passenger.ulyaoth.net” to the domain name you will use.

Step 9: Open passenger.conf and add the following:
$ sudo vi /etc/nginx/conf.d/passenger.conf

add the following:

passenger_pre_start http://passenger.ulyaoth.net/;
passenger_min_instances 2;
passenger_max_pool_size 4;

Of course change “passenger.ulyaoth.net” to the website you use in the nginx.conf “server_name” block at step 10.

you should this config now:

passenger_log_level 2;
passenger_log_file /var/log/passenger/passenger.log;
passenger_pre_start http://passenger.ulyaoth.net/;
passenger_min_instances 2;
passenger_max_pool_size 4;
passenger_instance_registry_dir /var/cache/nginx/passenger_temp/;
passenger_root /etc/nginx/modules/passenger;
passenger_ruby /usr/bin/ruby;

Change everything accordingly to what you will use! For the “passenger_pre_start” make sure you use the domain you used in the vhost above.

Step 10: Enable the Passenger module
$ sudo vi /etc/nginx/nginx.conf

and now add the following line under the load modules comment:
load_module modules/ngx_http_passenger_module.so;

Step 11: Download a test file to see if passenger works.
$ sudo wget https://raw.githubusercontent.com/sbagmeijer/ulyaoth/master/guides/passenger/app/config.ru -O /usr/share/nginx/ulyaoth/config.ru

Step 12: Start Nginx
$ sudo systemctl start nginx.service
If you now browse to your website you should see it running:

Some notes:
Please be aware for my example I used rails if you did need this then do not install it of course also the example above is a quick way never run a website in production as root so make sure you run passenger as a different user.

For more information on passenger option please have a read through their extensive information page on:
https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html

Related posts

logstash-forwarder and grok examples

Sjir Bagmeijer

How to install MongoDB 3.0 in replication on Windows Server 2012 R2

Sjir Bagmeijer

Install WordPress on Windows Server 2012 R2 with MariaDB 10.0 in replication.

Sjir Bagmeijer