Nginx (Engine-X) HTTP server is one of the most popular HTTP servers in used across the Internet. It powers some of the largest and most popular webistes you visit online. This brief tutorial shows students and new users how to install Nginx webserver on Ubuntu 17.10.
Nginx is a lightweight, stable, production-ready HTTP server that can be used by anyone to create powerful and dynamic websites. It can also serve as a reverse proxy server which makes a great choice for busy and popular websites.
This post should be short, easy to read and follow, even for new users.
Step 1: Install Nginx
Nginx packages are available in Ubuntu default software repository, so all one has to do is run the apt commands to install it. To do that, run the commands below.
sudo apt update sudo apt install nginx
Step 2: Allow HTTP Traffic
Now that Nginx is installed, continue below to configure Ubuntu firewall to allow HTTP traffic. By default Ubuntu firewall isn’t enabled. However, in some cases the firewall is turned for security reasons.
If Ubuntu firewall is enabled, the single line commands below should allow HTTP traffic on both port 80 and port 443.
sudo ufw allow 'Nginx Full'
If you check the firewall status, you should see that HTTP Full is allowed
sudo ufw status
The result should show that Nginx HTTP traffic is allowed from anywhere, including v6 traffic.
Status: active To Action From -- ------ ---- Nginx Full ALLOW Anywhere Nginx Full (v6) ALLOW Anywhere (v6)
At this point, you should now be able to access Nginx default website page if you browse to the server IP address or hostname. The default page should look like the one below.
Nginx is now fully installed and ready to be configured.
Step 3: Manage Nginx
The commands below allow you to stop, start, disable or enable Nginx to always start up when the server boots up.
sudo systemctl stop nginx.service sudo systemctl start nginx.service sudo systemctl enable nginx.service sudo systemctl disable nginx.service
Step 4: Nginx Folders
When you install Nginx HTTP server there will be additional folders created on your server. These folders contain configuration files, settings and other files. Below you’ll find some Nginx folders and what they’re used for:
- /etc/nginx/ –> Apache2 default configuration directory
- /etc/nginx/nginx.conf –> Nginx main configuration file
- /etc/apache2/sites-available/ –> Websites configuration files are stored here
- /etc/apache2/sites-enable/ –> Websites configurations are enabled here
- /var/www/html/ –> This is the default DocumentRoot for Nginx
The above directories are the most used on Ubuntu server.
This is how one installs Nginx HTTP server on Ubuntu. Now you’ve installed Nginx, go ahead and dive into how to configure more advanced settings and how to host a website.
You may also like the post below: