How To Install Nginx on Ubuntu 18.04 LTS

Install Nginx on Ubuntu 18.04 LTS

In this tutorial we will show you how to install Nginx on your Ubuntu 18.04 LTS. For those of you who didn’t know, Nginx is a powerful web server software that can be used on your server. It is also known for its high performance and low memory usage which will allow fewer resources to be used but getting the job done efficiently. A popular set up is to use it as a proxy for Apache, which can then serve application requests.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Nginx on a Ubuntu 18.04 (Bionic Beaver) server.

Install Nginx on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

Step 2. Installing Nginx.

Installing nginx package on Ubuntu 18.04 Bionic Beaver) is as easy as running:

After that, run the commands to enable Nginx to automatically startup when your server starts:

To test Nginx setup, open your browser and browse to the server hostname or IP address and you should see Nginx default test page as shown below:

Install Nginx on Ubuntu 18.04 LTS

Step 3. Configure Nginx.

Nginx site-specific configuration files are kept in /etc/nginx/conf.d/. Generally you will want a separate file in this directory for each domain or subdomain you will be hosting.

  • Copy the default configuration file. Replace with your website’s domain name or your public IP address.
  • Open your site’s configuration file in a nano text editor. Replace in the server_name directive with your site’s domain name or IP address. If you already have content ready to serve (such as a WordPress installation) replace the path in the root directive with the path to your site’s content:

Test your configuration for errors:

Step 4. Configure the Firewall for Nginx.

Firewall software needs to be adjusted to allow access to the service. Nginx registers itself as a service with ufw upon installation, making it straightforward to allow Nginx access:

Congratulations! You have successfully installed Nginx. Thanks for using this tutorial for installing Nginx web server in Ubuntu 18.04 LTS (Bionic Beaver) system. For additional help or useful information, we recommend you to check the official Nginx web site.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!