How To Set Rails On Nginx Ubuntu 18.04
Step 1: Install Ruby Using RVM
The first step for setting up Ruby on Rails on an Ubuntu 18.04 server with Nginx installed is to install Ruby, which can be done with RVM. RVM stands for Ruby Version Manager and is used to manage all the different versions of Ruby that you might want to use.
You can install RVM with the following command:
$ curl -L https://get.rvm.io | bash -s stable
Once the installation has completed, you can check the version of RVM installed with the following command:
$ rvm -v
Once you have confirmed that RVM is installed, you can then install the latest version of Ruby:
$ rvm install 2.6.3
The above command will install the latest version of Ruby, but you can also specify a specific version if needed. To do this, simply add the version number of the version you wish to install:
$ rvm install 2.5.5
By default, the latest version of Ruby will be set as the default version, but if you wish to use a specific version, you can use the following command:
$ rvm use 2.5.5
You can check which version of Ruby you are currently using with the following command:
$ ruby -v
Step 2: Install Bundler
Once Ruby is installed, the next step is to install Bundler. Bundler is a tool that helps you manage your application’s dependencies. You can install Bundler with the following command:
$ gem install bundler
Once Bundler is installed, you can check the version with the following command:
$ bundler -v
Step 3: Install Rails
Once Ruby and Bundler are installed, the next step is to install Rails. Rails is the framework used to create web applications using Ruby. You can install Rails with the following command:
$ gem install rails
Once Rails is installed, you can check the version with the following command:
$ rails -v
Step 4: Install Nodejs
Nodejs is a JavaScript runtime that is often used in the development of web applications. You can install Nodejs with the following command:
$ sudo apt-get install nodejs
Once Nodejs is installed, you can check the version with the following command:
$ node -v
Step 5: Install Nginx
Once Ruby, Bundler, Rails, and Nodejs are installed, the next step is to install Nginx. Nginx is a web server that is used to serve your web applications. You can install Nginx with the following command:
$ sudo apt-get install nginx
Once Nginx is installed, you can check the version with the following command:
$ nginx -v
Step 6: Configure Nginx
Now that you have all the components installed, the final step is to configure Nginx to serve your Rails application. To do this, you will need to create a configuration file in the /etc/nginx/sites-available directory. You can create a configuration file using your favorite text editor (e.g., nano):
$ sudo nano /etc/nginx/sites-available/myapp
Once the configuration file is open, add the following lines of code to the file:
server {
listen 80;
server_name myapp.example.com;
root /home/user/myapp/public;
passenger_enabled on;
}
Save the file and exit the editor. You can then enable the configuration file with the following command:
$ sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/myapp
At this point, you can check the syntax of the configuration file and make sure everything is correct with the following command:
$ sudo nginx -t
If everything is correct, you can then restart Nginx with the following command:
$ sudo service nginx restart
Conclusion
In this tutorial, we have showed you how to set up Ruby on Rails on an Ubuntu 18.04 server with Nginx installed. We have covered the installation of the Ruby version manager, the installation of the latest version of Ruby, the installation of Bundler, the installation of Rails, the installation of Nodejs, and the installation of Nginx. We have also covered how to configure Nginx to serve your Rails application. We hope you have found this tutorial helpful.
Thank you for reading this article. Please read our other articles for more interesting topics.
Related Posts:
- Replace Apache To Nginx Ubuntu 18 Replace Apache To Nginx Ubuntu 18 Installing Nginx Ubuntu 18 uses Nginx as its default web server, and it is pre-installed. However, if you want to use a fresh version…
- What Is The Difference Between Uwsgi And Nginx What Is The Difference Between Uwsgi And Nginx? What Is Uwsgi? Uwsgi stands for “Unicorn web server gateway interface”. It is a powerful, highly configurable and widely used web server…
- Ubuntu 16.04 Nginx-Extras Ubuntu 16.04 Nginx-Extras Introduction to Nginx-Extras on Ubuntu 16.04 Nginx-Extras are a set of extra features for Nginx, such as WebDAV, Secure Token (STS),gzip precompression, and GeoIP. All of these…
- How To Deactive Nginx Ubuntu How To Deactivate Nginx Ubuntu Introduction Nginx is a web server that’s popular in the Linux world because of its simple configuration, scalability, and performance. The Apache httpd web server…
- Setup Wordpress With Memcached And Nginx Setup Wordpress With Memcached and Nginx Installing Memcached Memcached is a distributed in-memory caching system used to speed up web applications such as WordPress. It stores data in memory and…
- Debian Install Nginx Php Mysql Phpmyadmin On Debian 9 Debian Install Nginx Php Mysql PhpMyAdmin On Debian 9 What Is Debian 9? Debian 9 (codenamed “stretch”) is the most recent stable version released by the Debian project, the developers…
- 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…
- Cara Install Nginx Ubuntu 14.04 Cara Install Nginx Ubuntu 14.04 Step 1: Update the Software Packages The first step in installing Nginx is to update the software packages in Ubuntu 14.04. This can be done…
- Install Nginx Php Mysql Phpmyadmin Ubuntu 18.04 Install Nginx Php Mysql Phpmyadmin Ubuntu 18.04 Introduction In this article, we will demonstrate how to install Nginx, PHP, MySQL, and phpMyAdmin on an Ubuntu 18.04 server. Nginx is a…
- Install Mysql Pada Nginx Pada Ubuntu Install Mysql Pada Nginx Pada Ubuntu Overview of Nginx and Its Benefits Nginx is a web server, reverse proxy server, and mail proxy server application that is open-source and available…
- Nginx Php Fpm 7.2 Nginx Php Fpm 7.2 Introduction to Nginx and PHP-FPM Nginx is an open-source web server, reverse proxy server, and load balancer. It is known for being lightweight and fast, and…
- Bash Install Nginx On Ubuntu How To Install Nginx On Ubuntu What is Nginx? Nginx is a web server that is gaining popularity in the world of web hosting. Nginx is an open source web…
- Virtualhost Nginx Ubuntu 16.04 Virtualhost Nginx Ubuntu 16.04 Introduction to Virtualhost Virtualhost is a software configuration option in web servers including Apache, Nginx, and more that allows a web server to host multiple web…
- User Nginx Does Not Exist Centos User Nginx Does Not Exist Centos What is Nginx? Nginx, pronounced “engine-x”, is an open source web server, reverse proxy server, IMAP/POP3 proxy server, and HTTP cache server. Nginx has…
- Setting Php Nginx Ubuntu Vps Setting Up a PHP, Nginx, and Ubuntu VPS What is a VPS? A Virtual Private Server (VPS) is a type of virtualized hosting. It works in the same way as…
- Easyengine Detected A Previously Installed Nginx Package Easyengine Detected A Previously Installed Nginx Package What is EasyEngine? EasyEngine is a command line tool that is used for installing, configuring, and managing web servers. It provides a simple…
- 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…
- Failed To Start Nginx Service In Ubuntu Failed to Start Nginx Service in Ubuntu What is Nginx? Nginx is an open-source web server written in C, designed for high performance and stability. Nginx is one of the…
- Install Laravel 5.8 Nginx Php7.3 Install Laravel 5.8 Nginx Php7.3 Overview Installing Laravel 5.8 on a Nginx server running PHP 7.3 can be a tricky task. This tutorial explains how to install the popular open…
- Centos 6 Nginx Multiple Php Version Centos 6 Nginx Multiple PHP Versions What is CentOS 6? CentOS 6 is a Linux-based operating system. It is a free, open-source operating system that is based on Red Hat…
- Install Nginx Mysql Phpmyadmin Ubuntu Install Nginx Mysql Phpmyadmin Ubuntu 1. Introduction In today's tutorial, we will show you how to install Nginx, MySQL, and phpMyAdmin on Ubuntu 20.04. Nginx is an open source web…
- Nginx Wordpress Ubuntu 18.04 Nginx Wordpress Ubuntu 18.04 Introduction to Nginx Nginx is a web server software for hosting websites and applications. It is open-source and highly configurable, making it a popular choice for…
- Php-Fpm Nginx Ubuntu 18.04 PHP-FPM & Nginx on Ubuntu 18.04 Introduction to PHP-FPM PHP-FPM (FastCGI Process Manager) is an implementation of FastCGI, which is a standard protocol for interfacing external applications with web servers.…
- Install Postgis Ubuntu 18.04 Nginx Install Postgis Ubuntu 18.04 Nginx What is Postgis? Postgis is a Postgres-based open source geographic information system (GIS) that enables users to store, query, and analyze spatial data stored in…
- Ubuntu 18.04 Letsencrypt Nginx Ubuntu 18.04 Letsencrypt Nginx What is Ubuntu and Why is it Used for Nginx? Ubuntu is a Linux-based operating system designed for open-source use. It is regularly updated, secure, and…
- Using Helm To Install Nginx Ingress Using Helm To Install Nginx Ingress What is Helm? Helm is an open-source Kubernetes package manager. It is used to install and manage applications on Kubernetes clusters. Helm works with…
- Upgrade Nginx Ubuntu 18.04 Upgrade Nginx Ubuntu 18.04 Getting Started with Nginx Ubuntu 18.04 Installation Nginx is a high performance web server and reverse proxy. It is written in C and has ways to…
- Restart Nginx Ubuntu 16.04 Restart Nginx Ubuntu 16.04 Why do you Need to Restart Nginx? When you deploy your web application, sometimes you need to restart your web server (Nginx) to ensure that all…
- 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…
- Nginx Install Ssl Certificate Ubuntu Nginx Install SSL Certificate Ubuntu What is Nginx? Nginx is a free, open-source web server that is used for powering websites. It is popular for its speed, scalability, and stability,…