NGINX Web Server Installation
NGINX Web Server Installation
Open the terminal on Ubuntu and run the following command to ensure that all packages on
the OS are up to date:
$ sudo apt-get update
Since Nginx is available in the default repository of Ubuntu, it is possible to install it from
these repositories using the apt packaging system.
$ sudo apt-get install nginx
next →← prev
o Using a pre-built binary: - This method is much easiest and faster method.
o Building it up from source: - This method provides the ability to include various
third-party modules that make Nginx even more powerful.
Following are the steps which will show us how to install Nginx on our Debian or Ubuntu
system:
Step 1: First of all, let's update our local package index so that we have
access to the most recent package listings.
Open the terminal on Ubuntu or Debian and run the following command to ensure that all
packages on the OS are up to date:
1. sudo apt-get update
Since Nginx is available in the default repository of Debian or Ubuntu, it is possible to
install it from these repositories using the apt packaging system.
1. sudo apt-get install nginx
Once it is done, use the following command to see the process for the webserver in a
running state.
1. ps -ef | grep nginx
Adjusting the firewall to access Nginx
For accessing the Nginx from the web server, we have to allow access to the services
from outside.
To see the list of profiles available to allow from the firewall, use the following command:
Here,
$ sudo ufw allow 'Nginx Full'
$ sudo ufw allow 'Nginx HTTP'
To allow only Nginx HTTPS port 443, use the following command:
$ sudo ufw allow 'Nginx HTTPS'
$ systemctl status nginx
We can access the default Nginx page to make sure that the software is running properly.
We can access this through our server's IP address.
We should see the "Welcome to Nginx" default page. If we see that page, then we can be
sure that Nginx has been installed properly.
This page is normally included with Nginx to show us that the server is running properly.
Now all you have to do is create a Web Page and save it.
$cd /etc/nginx
Then edit a file nginx.conf and clear all the content and configure with your web page:
$ vi nginx.conf
http {
include mime.types;
server {
listen 80;
server_name “example.com”;
}
After saving this file we need to restart the NGINX services and check the status:
We can access our Web page to make sure that its working fine. We can access this through
our server's IP address.