Install Nginx Passenger Ubuntu 16.04
Installing Nginx On Ubuntu 16.04
Nginx is an open source web server that can be used to create web and application servers. It is a powerful and stable web server that is commonly used on Linux based operating systems. The Nginx web server is an alternative to the popular Apache web server. This guide will show you how to install Nginx on Ubuntu 16.04.
To begin, log in to your Ubuntu 16.04 server instance as a user with sudo privileges. Once you’ve logged in, update the system package databases to ensure the latest packages available are installed. We can do this by calling apt-get update from the command line.
Once the database is updated, we can install the Nginx web server with the apt-get command below:
sudo apt-get install nginx
The install process will ask you to confirm the installation, so press Y
when it appears. Once the install has finished, you can check the status of the service with the command below:
sudo systemctl status nginx
The Nginx web server is now installed and running. We can confirm this by looking at the output from the command used earlier. You should see a line that reads “active (running)” near the top.
Configuring Nginx On Ubuntu 16.04
Now that you have Nginx installed on your Ubuntu 16.04 server, you can begin to configure it. You can look at the Nginx configuration file like a roadmap of how the web server is set up. It defines the virtual hosts, server blocks, configurations and also includes location and directory blocks.
The configuration file for the Nginx web server is located at /etc/nginx/nginx.conf. This file should already exist if you are running Nginx web server on your server instance. If not, you can create it with the touch command.
sudo touch /etc/nginx/nginx.conf
Open the file in your editor of choice and add the following content:
user www-data;
worker_processes auto;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name example.com;
root /var/www/example.com/public;
}
}
This will set up the server block for your domain. After making the changes, you will need to restart the Nginx service for the changes to take effect.
sudo systemctl restart nginx
Installing Passenger For Nginx On Ubuntu 16.04
Now that we have our web server set up, we can move on to installing Passenger. Passenger is an application server for Ruby, Python, Node.js and Meteor applications. It is an open source project that makes it easy to deploy web applications on your Ubuntu server.
To install Passenger, we will first need to grab the official package from the Passenger website. Ubuntu 16.04 uses the Ubuntu 14.04 package since it is still based off of Ubuntu 14.04, so grab the package for that distribution.
wget https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release/5.0.30/passenger_5.0.30-xenial_amd64.deb
Once the package is downloaded, we can install it on our Ubuntu server with the dpkg command below:
sudo dpkg -i passenger_5.0.30-xenial_amd64.deb
This will install Passenger on our Ubuntu 16.04 server. Once the install is complete, we can configure the Passenger module for Nginx. We can do this by editing the Nginx configuration file.
Open the Nginx configuration file with your favorite text editor and add the following content:
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
This will enable the Passenger module for Nginx. After making your changes, restart the Nginx service for the changes to take effect:
sudo systemctl restart nginx
Installing Application Dependencies With Bundler
Now that you have Passenger installed, you can begin to deploy your application. Before you deploy your application, you will first need to install the application dependencies. This can be done with the Bundler gem.
In the project directory of your application, install the Bundler gem with the command below:
gem install bundler
Once the gem is installed, you can install the application dependencies with the command below:
bundle install --path vendor/bundle
This will install all of the gem dependencies specified in your Gemfile. Once this is complete, you can move on to deploying your application.
Deploying Your Application With Nginx and Passenger
Now we can deploy our application with Nginx and Passenger. We can do this by creating a new Nginx site configuration in the /etc/nginx/sites-available directory.
Create a new file called example.com in the /etc/nginx/sites-available directory with the following content:
server {
listen 80;
server_name example.com;
root /var/www/example.com/public;
passenger_enabled on;
}
This will set up the server block for your application. After creating the file, you can enable it by creating a symbolic link from the sites-enabled directory.
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
Finally, restart the Nginx service for the changes to take effect:
sudo systemctl restart nginx
Your application will now be accessible in a web browser like this: http://example.com
Managing Passenger With The Passenger Nginx Module
Now that your application is up and running, we can begin to look at managing it with the Passenger Nginx module. This module allows us to easily set up monitoring, restarting and scaling of our Passenger instance.
To enable the Passenger Nginx module, we will need to edit the Nginx configuration file. Open the Nginx configuration file and add the following content to the server block:
passenger_enabled on;
passenger_monitor_interval 5;
passenger_max_instances_per_app 20;
Once you have made the changes, save and close the file, then restart the Nginx service for the changes to take effect. This will enable the Passenger Nginx module.
Conclusion
In this guide, we have showed you how to install Nginx on Ubuntu 16.04 and configure it to serve your application with Passenger. We have also touched on how to manage your Passenger instance with the Passenger Nginx module.
FAQ
Q: What is Nginx?
A: Nginx is an open source web server that is used to create web and application servers. It is a powerful and stable web server that is commonly used on Linux based systems.
Q: Where is the Nginx configuration file located?
A: The Nginx configuration file is located at /etc/nginx/nginx.conf
Related Posts:
- How Use Nginx Mysql Ubuntu How to Use Nginx, MySQL and Ubuntu What is Nginx? Nginx is an open source web server and reverse proxy software written by Igor Sysoev. It is a popular choice…
- Install Wordpress On Nginx Ubuntu Install Wordpress On Nginx Ubuntu Introduction WordPress is a popular open-source blogging platform and content management system (CMS). It is made to be used on the internet, and it is…
- Install Paid Ssl Nginx Ubuntu 18.04 Install Paid SSL Nginx Ubuntu 18.04 What Is Nginx? Nginx is an open-source web server and reverse proxy used in many applications worldwide. It is a lightweight, high-performance server that…
- Nginx Ssl Ubuntu 16.04 Nginx SSL Ubuntu 16.04 What is SSL and Nginx? SSL stands for Secure Sockets Layer. It is a protocol used to encrypt communications over the internet. It is a secure…
- Completely Uninstall Phpmyadmin On Nginx Ubuntu 18.04 Completely Uninstall PhpMyAdmin On NGINX Ubuntu 18.04 Introduction PhpMyAdmin is a very popular web-based graphical tool for managing MySQL databases in the Ubuntu operating system. It is used by web…
- Install Nginx And Php On Ubuntu Install Nginx And Php On Ubuntu A Comprehensive Tutorial to Install Nginx And Php On Ubuntu Nginx and PHP are two of the most popular web server and scripting language…
- Install Wordpress On Ubuntu 18.04 Nginx Install WordPress On Ubuntu 18.04 Nginx Introduction To Ubuntu And Nginx Ubuntu is a popular open-source operating system which has gained immense popularity over the years. It is easy to…
- Install Nginx-Naxsi Ubuntu 16.04 Install Nginx-Naxsi on Ubuntu 16.04 Understanding Nginx and Naxsi Nginx is a high-performance web server which can also be used as a reverse proxy or load balancer. Naxsi is a…
- Letsencrypt Nginx Ubuntu 16.04 Let’s Encrypt Nginx on Ubuntu 16.04 What is Let’s Encrypt? Let’s Encrypt is an open source Certificate Authority (CA) for issuing free SSL/TLS certificates. SSL/TLS certificates are used to encrypt…
- Reverse Proxy Nginx Ubuntu 18.04 Reverse Proxy Nginx Ubuntu 18.04 Introduction Reverse Proxy is a type of proxy server that forwards requests to another server. It is mainly used by web servers, such as Nginx,…
- Install Nginx 1.16 Ubuntu Install Nginx 1.16 Ubuntu Introduction to Nginx 1.16 Nginx 1.16 is a web server that helps you to serve web content quickly, efficiently and securely. It is especially popular with…
- Perfect Server Ubuntu 18.04 Nginx Perfect Server Ubuntu 18.04 Nginx 1. Introduction Ubuntu is one of the most popular Linux distributions. It is popular due to its user friendliness and availability of excellent free software…
- Error Nginx When Installing Certbot Ubuntu Error Nginx When Installing Certbot Ubuntu What is Nginx? Nginx is a web server software often used to serve web pages. It is known as a high-performance web server and…
- How To Install Moodle On Nginx Postgresql Ubuntu How To Install Moodle On Nginx Postgresql Ubuntu Overview of Moodle and Requirements Moodle is an open-source learning management system (LMS) used by educators, businesses, and other organizations to create…
- Install Nginx Ubuntu 18.08 Local Install Nginx on Ubuntu 18.04 Local Installing Nginx on Ubuntu 18.04 can be accomplished quickly and in several different ways. Depending on your needs, some methods may be better suited…
- Remove Nginx And Install Apche Ubuntu 18.04 Remove Nginx And Install Apche Ubuntu 18.04 Introduction The world of web servers is quite vast and different web servers have different applications and preferences. If you are new to…
- Google Cloud Ubuntu 16 Install Nginx Php Google Cloud Ubuntu 16 Install Nginx Php 1. What is Nginx? Nginx is a powerful open source web server. It is used to serve web pages to the internet and…
- Step By Step Install Nginx And Phpmyadmin On Ubuntu Step By Step Install Nginx And Phpmyadmin On Ubuntu Introduction Setting up a web server on Ubuntu is easy and straightforward. Nginx is a popular web server for Ubuntu, and…
- Install Php Nginx Mysql Ubuntu 18.04 Install Php Nginx Mysql Ubuntu 18.04 What is PHP, Nginx, and MySQL PHP is a popular and powerful scripting language that can be used to create dynamic web pages, web…
- How To Check Whether 2 Nginx Is Installed In Ubuntu How To Check Whether 2 Nginx Is Installed In Ubuntu Overview Nginx is an open-source web server that is used to host web sites and applications. It is very popular…
- Ubuntu Server18 How To Enable Nginx Pdo Mysql Ubuntu Server18: How to Enable Nginx Pdo Mysql As a developer, you may have heard of Nginx, PDO, and MySQL – all are essential components of web applications. Nginx is…
- Install Mariadb Nginx Debian 9.7 Install Mariadb and Nginx on Debian 9.7 Overview of Installing MariaDB and Nginx on Debian 9.7 Installing MariaDB and Nginx on Debian 9.7 can be an essential step when setting…
- How To Login Phpmyadmin In Nginx Server Ubuntu How To Login Phpmyadmin In Nginx Server Ubuntu What is Nginx & phpMyAdmin Nginx is a web server software that is commonly used on Linux-based systems, though it works on…
- How To Install Cachet Nginx How To Install Cachet Nginx Overview Cachet is an open-source monitoring platform that is widely used by web developers, DevOps engineers, and system administrators for monitoring the performance of a…
- Laravel Nginx Config Ubuntu 18 Laravel Nginx Config Ubuntu 18 Introduction Laravel is a powerful web-based MVC (Model-View-Controller) framework used by developers to create web applications, websites and APIs. It is based on the popular…
- Remove Nginx Full Complete On Ubuntu 18 Remove Nginx Full Complete On Ubuntu 18 Uninstallating Nginx From Ubuntu Ubuntu is one of the most popular Linux-based operating systems, and it has a wide variety of programs available…
- Install Laravel Ubuntu 16.04 With Nginx Web Server Install Laravel Ubuntu 16.04 With Nginx Web Server Introduction Laravel is one of the most popular expressive, elegant, and robust PHP frameworks available today. It is an open source framework…
- Apt-Get Install Nginx Php Mysql Apt-Get Install Nginx Php Mysql What is Apt-Get? Apt-Get is a powerful and innovative command line tool used by Linux-based operating systems such as Debian, Ubuntu, Linux Mint and others.…
- Install Phpmyadmin On Nginx Ubuntu 18.04 Install Phpmyadmin On Nginx Ubuntu 18.04 Introduction PhpMyAdmin is one of the most popular and widely used web-based database management tools available. It is used for administering, managing and maintaining…
- E Unable To Locate Package Nginx E Unable To Locate Package Nginx What is Nginx? Nginx is an open-source web server and reverse proxy that is used for hosting websites, web applications, and other network services.…