• Skip to content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
  • About
  • Design
  • Development
  • Deployment
  • More…
    • Privacy Policy
    • Terms of use
    • Disclaimer
    • Comment Policy
  • Contact

Website Vidya

Design. Develop. Deploy

  • Server
  • WordPress
You are here: Home / Deployment / How To Install Nginx on Ubuntu 18.04 LTE

How To Install Nginx on Ubuntu 18.04 LTE

January 31, 2019 By Rajesh Rai Leave a Comment

Table of Contents

  • Introduction
  • Prerequisites
    • Step 1 – Install Nginx on Ubuntu
    • Step 2 – Configure the Firewall
    • Step 3 – Checking Your Server
    • Step 4 – Managing Nginx and it’s Processes

Introduction

Nginx is one of the most popular and powerful web servers in the world used my some of the best, largest and high-traffic websites. Its asynchronous architecture makes it the most powerful, most popular and best performing web servers available.

I personally prefer Nginx web server for my all personal and client’s website. It is more powerful, and resource-friendly than apache.

If you are looking to install Ubuntu (Linux) with Nginx, MySQL and PHP (LEMP Stack Installation) consider reading:

How to Install LEMP Stack – Ubuntu (Linux), NGINX, MySQL, PHP

For Ubuntu Ubuntu (Linux), Apache, MySQL and PHP (LAMP Stack) Installation guide read:

How To Install LAMP Stack – Ubuntu (Linux), Apache, MySQL, PHP

Prerequisites

Let’s first update your server by running the following command:

sudo apt-get
update && sudo apt-get upgrade

Step 1 – Install Nginx on Ubuntu

Once you are done updating your server, install Nginx on Ubuntu from its default repository using the apt packaging system by running the following command:

sudo apt-get install nginx

Step 2 – Configure the Firewall

Before testing the Nginx installation on Ubuntu, let’s first adjust the firewall to allow access to the service. Nginx by default registers itself as a service with ufw.

You can check the status by running the following command:

Output
Available applications:
  Nginx Full
  Nginx HTTP
  Nginx HTTPS
  OpenSSH

Nginx Full: It means the port 80 is open (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted) are open for http protocol. So that anyone can access the web server by entering the IP address in the web browser.

Nginx HTTP: This only opensport 80 (normal, unencrypted web traffic)

Nginx HTTPS: This openport 443 (TLS/SSL encrypted)

It is important that we enable all the required profiles for HTTP and HTTPS.

You can see the status by running the following command:

sudo
ufw status

You should see the allowed HTTP and HTTPS traffic. You can see the output below:

Status: active

To                         	Action      	From
--                         	------      	----
Nginx Full                 	ALLOW       	Anywhere
Nginx HTTP                 	ALLOW       	Anywhere
Nginx HTTPS                	ALLOW       	Anywhere
Nginx Full (v6)            	ALLOW       	Anywhere (v6)
Nginx HTTP (v6)            	ALLOW       	Anywhere (v6)
Nginx HTTPS (v6)           	ALLOW       	Anywhere (v6)

Step 3 – Checking Your Server

Now you can check the status of your Nginx web server by typing the following command in the terminal:

systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
   Active: active (running) since Thu 2019-01-24 13:12:02 IST; 5 days ago
  Process: 22119 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5
  Process: 22125 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (cod
  Process: 22122 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process
 Main PID: 22127 (nginx)
   CGroup: /system.slice/nginx.service
           ├─22127 nginx: master process /usr/sbin/nginx -g daemon on; master_pr
           └─22128 nginx: worker process

Warning: Journal has been rotated since unit was started. Log output is incomple
lines 1-12/12 (END)

We can see that the Nginx is started successfully.

So now you need to put the IP address of your server in the web browser to see the Nginx welcome page.

In case you don’t know the IP address of your server, run the following command to display the IP address:

ip addr show
eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

Now when you enter the IP address of your server in the browser, you get to see the Welcome page by Nginx.

If you see the above page successfully by running the IP address in the browser, mean that Nginx is configured correctly.

Step 4 – Managing Nginx and it’s Processes

Below are the some of the very useful command that you will need while managing Nginx on your server.

To stop your web server:

sudo
systemctl stop nginx 

or

sudo
service nginx stop

or

sudo
/etc/init.d/nginx stop

To start the web server:

sudo
systemctl start nginx 

or

sudo
service nginx start

or

sudo
/etc/init.d/nginx start

To restart the web server:

sudo
systemctl restart nginx

or

sudo
service nginx restart

or

sudo
/etc/init.d/nginx restart

To reload the Nginx without dropping the connection you can run the reload command:

sudo
systemctl reload nginx

or

sudo
service nginx reload

or

sudo
/etc/init.d/nginx reload

In any case if you need to disable your web server, you might want to run the disable command:

sudo
systemctl disable nginx

To enable web server:

sudo
systemctl enable nginx

That’s it!

You are done installing and configuring Nginx web server. For more information regarding Nginx documentation, check official documentation by Nginx.

If you need to install a WordPress installation using Ubuntu, Nginx, and MySQL read WordPress Installation guide on LEMP with Ubuntu.

I hope this guide will help you to install Nginx on Ubuntu. If you have any other application to install, you can put it in the comment section or mail me on my email address. I will personally get in touch with you to help your setup your application.

Rajesh Rai
Rajesh Rai

Rajesh Rai is an Entrepreneur, Web Developer, Digital Marketer & a student for life. He has helped over 100 companies to grow their businesses on the Internet.

Filed Under: Deployment, Server Tagged With: Linux, NGINX, php, Ubuntu

Primary Sidebar

GET OUR NEWSLETTER

Get instant access to my weekly newsletter where I share my best tips about Website Design, Development & Deployement!

COME HANG OUT WITH US

  • Facebook
  • Instagram
  • LinkedIn
  • Pinterest
  • RSS
  • Twitter
  • YouTube

Recent Posts

  • Fix 413 Request Entity Too Large Error on Nginx & Apache
  • How to Install MongoDB on Ubuntu 18.04 LTE
  • Get Royalty Free Stock Photos with Google
  • 500+ Photoshop Shortcuts to Speed Up Your Workflow
  • How to Install PHPMyAdmin on Ubuntu?

Footer

About Website Vidya

Welcome to WebsiteVidya.com – a Blog dedicated to people with Graphics & Web Designing, Development and Web Server skills.

My name is Rajesh Rai and I’m a full-time blogger making a living from blogs like Search Engine Bay, Search Engine Examiner, and Sharestrap.

Follow Us

  • Facebook
  • Instagram
  • LinkedIn
  • Pinterest
  • Tumblr
  • YouTube

Recent Posts

  • Fix 413 Request Entity Too Large Error on Nginx & Apache February 22, 2019
  • How to Install MongoDB on Ubuntu 18.04 LTE February 8, 2019
  • Get Royalty Free Stock Photos with Google February 2, 2019
  • 500+ Photoshop Shortcuts to Speed Up Your Workflow February 1, 2019
  • How to Install PHPMyAdmin on Ubuntu? February 1, 2019

Quick Links

  • About
  • Disclaimer
  • Privacy Policy
  • Terms of use
  • Contact

Copyright © 2019 · Website Vidya · Proudly Powered by Genesis Framework

We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used
to manage this website,
we request you to whitelist our website
in your adblocking plugin.