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:
- 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…
- How To Install Nginx On Centos 7 Rhel 7 How To Install Nginx On Centos 7 Rhel 7 Nginx is one of the most popular web servers around the globe – being an open-source application, it drives a large…
- Install Php5 Nginx Ubuntu 18.04 Install PHP5 Nginx Ubuntu 18.04 Understanding The Basics of Nginx and PHP Before we learn how to install Nginx and PHP on Ubuntu 18.04, it’s important to understand the basic…
- Nginx Always Displaying Default Page In Ubuntu Nginx Always Displaying Default Page In Ubuntu Introduction Ubuntu is one of the most popular Linux distributions and an immensely powerful and versatile operating system. It has a great package…
- Error Install Nginx On Ubuntu Error Install Nginx On Ubuntu What is Nginx? Nginx is a web server software used to host web applications. It is open source software developed by the open source community.…
- 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…
- 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…
- 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…
- 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…
- Add Php7.2 Curl To Nginx Add Php7.2 Curl To Nginx Overview In this article, we’ll discuss how to add Php7.2 with Curl module to Nginx. Since Php7.2 is the latest version of the PHP language,…
- 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…
- Nginx Ssl Configuration Ubuntu 18.04 Nginx Ssl Configuration Ubuntu 18.04 What is Nginx? Nginx is an open source web server and reverse proxy software. It is used to manage web traffic on the internet, like…
- 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…
- Hhvm Nginx Ubuntu 16.4 HHVM Nginx Ubuntu 16.4 What is HHVM? HHVM, also known as HipHop Virtual Machine, is a virtual machine developed by Facebook to speed up the execution of PHP code. It…
- Remove Apache2 Ubuntu And Change To Nginx Remove Apache2 Ubuntu And Change To Nginx What Is Apache2? Apache2 is an open-source web server software created and maintained by the Apache Software Foundation. It is one of the…
- 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…
- Ubuntu 18.04 Nginx Hide Port Ubuntu 18.04 Nginx Hide Port Introduction to Nginx with Ubuntu Nginx is an open source web server and reverse proxy software that is commonly used in Linux servers. It is…
- Tutorial Start Nginx Ubuntu Webserver Tutorial Start Nginx Ubuntu Webserver Step 1: Prerequisites Before we start configuring Nginx as a web server on Ubuntu, we need to make sure we have the following prerequisites: A…
- Boot Sidekiq Production Rails Passenger Nginx Boot Sidekiq Production Rails Passenger Nginx What is Sidekiq? Sidekiq is an open-source background processing framework written in Ruby. It is designed to process jobs asynchronously in the background. It…
- Rails Nginx Cannot Start Config.Ru Rails Nginx Cannot Start Config.Ru What Is Config.Ru? Config.ru is a file commonly used in Ruby on Rails applications that gives the application instructions on how to start up and…
- 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 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…
- How To Set Up Nginx Loadbalancer Ubuntu How To Set Up Nginx Loadbalancer Ubuntu Introduction to Nginx Loadbalancer Nginx Loadbalancer is a web application that lets you easily set up load balancing for your website. It is…
- 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.…
- Tutorial Install Nginx Di Ubuntu Vps Tutorial Install Nginx Di Ubuntu Vps Step 1: Install Nginx The first step to install nginx in your Ubuntu VPS is to install the nginx package. To do this, use…
- Ubuntu 16.04 Nginx Ipv6 Ubuntu 16.04 Nginx Ipv6 What is Ubuntu 16.04? Ubuntu 16.04 is a version of the Ubuntu Linux operating system for computers and servers. Ubuntu has been around since 2004, and…
- Stop Nginx Ubuntu 16.04 Stop Nginx Ubuntu 16.04 What is Nginx? Nginx is a web server and reverse proxy software. It is open source and widely used on the web. It is used to…
- 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…
- 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…
- 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…