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:
- 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,…
- Nginx Install Ssl Certificate Centos Nginx Install Ssl Certificate Centos Introduction The development of the internet and its associated technologies has made secure connections a must for anyone who wants to have a website accessible…
- 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…
- Start Nginx Service Centos 7 Start Nginx Service Centos 7 Before You Start: Server and Requirements If you are running a website or a web application on Centos 7, chances are you will be using…
- 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…
- Install Letsencrypt Debian 9 Nginx Install Letsencrypt Debian 9 Nginx What is Letsencrypt? Letsencrypt is an open source, free, automated SSL service that provides users with the ability to secure their websites and use HTTPS…
- Nginx Curl 58 Error With Ssl Certificate Nginx Curl 58 Error With SSL Certificate What is an SSL Certificate? An SSL (Secure Socket Layer) Certificate is a digital certificate that is used to establish an encrypted connection…
- 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…
- 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…
- Deploy Laravel Nginx Ubuntu 18 Deploy Laravel Nginx Ubuntu 18 Intro to Laravel Laravel is a free, open-source, Model-View-Controller (MVC) web framework written in PHP. It has become one of the most popular web development…
- Install Laravel Nginx 16.04 Install Laravel Nginx 16.04 What is Laravel? Laravel is an open source PHP framework designed to organize, develop, and easily deploy modern web applications. It is built on the Model-View-Controller…
- Install Webuzo Without Conlicting Nginx Centos 7 Install Webuzo Without Conlicting Nginx Centos 7 What is Nginx? Nginx is an open-source web server that was created and released in 2004. It is known for its speed, stability,…
- Install Webmin Plugin Nginx Ubuntu Install Webmin Plugin Nginx Ubuntu What is Nginx? Nginx is a web server that runs on the Linux operating system. It is a popular web server software and can handle…
- Failed To Restart Nginx.Service: Unit Nginx.Service Not… Failed To Restart Nginx.Service: Unit Nginx.Service Not Found What is Nginx? Nginx (Engine X) is a web server originally created by Igor Sysoev in 1996. It is now one of…
- Install Nginx On Centos 6 Install Nginx on CentOS 6 What is Nginx? Nginx is a web server and a reverse proxy server for HTTP, HTTPS, SMTP, POP3 and IMAP protocols, with a strong focus…
- Install Nginx Ubuntu 16.04 For Odoo Install Nginx Ubuntu 16.04 For Odoo Install Ubuntu Server 16.04 Before we can install Nginx for Odoo we need to install Ubuntu 16.04 on our server. Ubunutu 16.04 is still…
- Nginx Install Custom Directory Phpmyadmin Nginx Install Custom Directory PhpMyAdmin Introduction to Nginx and PhpMyAdmin Nginx is a web server and content caching solution used to host a variety of web applications. It is highly…
- Laravel 5.5 Configure Nginx Laravel 5.5 Configure Nginx Introduction To Nginx Nginx is a web server software often deployed as a reverse proxy. It is open-source and available to download for free. Nginx has…
- How To Install Flask Nginx On Ubuntu 1604 How To Install Flask Nginx On Ubuntu 1604 Introduction Flask is a web application framework based on Python. It is highly useful for web developers due to its flexibility and…
- Install Laravel 5.1 Ubuntu 16.04 Nginx Install Laravel 5.1 on Ubuntu 16.04 Nginx Introduction Laravel is a free, open-source PHP web application framework that is highly popular with modern web developers. It leverages an expressive and…
- Nginx Windows Execute Command Conf Nginx Windows Execute Command Conf What is Nginx for Windows? Nginx for Windows is an open-source web server used to run websites and web applications on Windows operating systems. It…
- Install Phpvirtualbox On Ubuntu 12.04 Nginx Install PHPVirtualbox on Ubuntu 12.04 Nginx What is PHPVirtualbox? PHPVirtualbox is a web-based management tool designed to assist the user in creating and managing virtualized environments. It is developed, maintained…
- 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,…
- How To Install Phpmyadmin On Nginx How To Install Phpmyadmin On Nginx Introduction PhpMyAdmin is an open source software program which is used to manage MySQL and MariaDB databases. It provides a graphical interface to execute…
- Centos 7 Install Nginx Php 7 Centos 7 Install Nginx Php 7 Nginx Server Overview and Prerequisites Nginx is a highly popular open source web server and reverse proxy software, known for its scalability and performance…
- Ubuntu Nginx Check Php Status Ubuntu Nginx Check Php Status Introduction Nginx is a widely used web server, created by Igor Sysoev back in 2004, intended to be faster and more efficient than previously available…
- Install Nginx On Debian 10 Install Nginx On Debian 10 Preface Nginx is a high performance web-server and one of the most popular web-servers used in the Linux world. Nginx is known for its robustness…
- 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…
- Install Phpmyadmin Nginx Ubuntu 16.04 Php 7 Install Phpmyadmin Nginx Ubuntu 16.04 Php 7 Introduction to PhpMyAdmin PhpMyAdmin is a web-based tool that enables the users to manage their MySQL databases. It also provides a graphical interface…
- 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…