Install Nginx as your default web server

This guide will help you how to setup Nginx web server for your server. I am using Almalinux 8 with 512 MB RAM. Nginx is very suitable for low RAM but high utilisation.

First, make sure you already inside vm and logged as root.

Login SSH

Since last 2023 GPG key for Almalinux has been changed, therefore need to update it first. You can refer to this blog.

rpm --import

After that we update all library.

dnf update -y
dnf install net-tools -y

This may take around 2-3 minutes to fully completed.

Now we are going install Nginx, we need to eliminate another web server. So we want to make sure Nginx is standalone web server.

systemctl stop httpd
systemctl disable httpd

As well we eliminate unused application to free up more RAM.

systemctl stop sendmail
systemctl disable sendmail
systemctl stop firewalld
systemctl disable firewalld

Now install epel-release to make sure we have latest Nginx version.

dnf install epel-release -y
dnf install nginx -y

Start and enable Nginx

systemctl start nginx
systemctl enable nginx

Nginx has been installed, now we need to verify see if it is running. Since you are under NAT VPS, then check which opened ports for you. There will be 25 total. For example I have 20150 port opened. Therefore, I will bind this port to my nginx.

vi /etc/nginx/nginx.conf

And change this line from :

listen       80 default_server;

Into :

listen       20150 default_server;

Save and check if the configuration is correct.

nginx -t

Then you may proceed to restart or reload.

systemctl reload nginx

Once opened, you should be able to access http://shared-ip-public:20150/

Nginx default page.

The default document root where you can upload your web files is under /usr/share/nginx/html

Please take a note, you can only create *.htm and *.html files only for standalone nginx web server. If you wish to make a website with this and wish to clean URL (no port seen on URL browser) then please submit a ticket, we will make a domain forwarding for you (include free SSL as well).

Leave a Reply 0

Your email address will not be published. Required fields are marked *