Nginx is a powerful, high-performance web server known for its ability to handle thousands of simultaneous connections with minimal resource usage. It’s a popular choice for hosting websites, serving static content, and even acting as a reverse proxy for load balancing and traffic distribution. Compared to other web servers, Nginx offers excellent speed, scalability, and efficiency.

In this guide, we’ll walk through the steps of installing and configuring Nginx on a VPS running AlmaLinux OS.

Prerequisites

Before getting started, make sure you already have:

  • A VPS or server running AlmaLinux OS
  • Root or sudo access via SSH
  • Firewalld installed (if you plan to configure firewall rules)

Step 1: Update Your Server

Start by logging into your server via SSH. Once connected, update your system packages:

dnf update -y

Keeping your server updated ensures you have the latest security patches and stability improvements.

Step 2: Check Available Nginx Modules

Nginx is provided via AppStream modules. To view the available versions, run:

dnf module list nginx

Step 3: Enable the Nginx Module

Reset any previously enabled versions of Nginx and enable the latest one. For example, to enable version 1.22:

dnf module reset nginx -y

dnf module enable nginx:1.22 -y

Step 4: Install Nginx

Now install Nginx with:

dnf install nginx -y

Step 5: Start and Enable Nginx

Enable Nginx to start automatically when your server boots, and start the service right away:

systemctl enable nginx –now

Check its status to confirm it’s running:

systemctl status nginx

Step 6: Fix the PID Error (If Needed)

If you encounter the common PID error when starting Nginx, create an override configuration to give systemd extra time:

mkdir -p /etc/systemd/system/nginx.service.d

printf “[Service]\nExecStartPost=/bin/sleep 0.1\n” > /etc/systemd/system/nginx.service.d/override.conf

systemctl daemon-reload

Step 7: Test and Restart Nginx

Always test configuration changes before restarting Nginx:

nginx -t

If no errors are shown, restart the service:

systemctl restart nginx

Step 8: Configure Firewall Rules

If Firewalld is enabled, allow HTTP and HTTPS traffic:

firewall-cmd –permanent –zone=public –add-service=http

firewall-cmd –permanent –zone=public –add-service=https

firewall-cmd –reload

Step 9: Verify Installation

Open your web browser and visit your server’s IP address or domain name. If Nginx is installed correctly, you’ll see the default Nginx welcome page.

Conclusion

With just a few steps, you’ve successfully installed Nginx on your AlmaLinux VPS. Nginx’s performance and scalability make it an excellent choice for hosting modern websites and applications.

At RackNerd, we provide affordable and reliable VPS hosting solutions to power your Nginx server. Whether you’re building a personal project or deploying a production environment, RackNerd has the right VPS plan for you. Explore our hosting services today at racknerd.com.

Server Hosting Solutions by RackNerd:

Shared Hosting
cPanel Web Hosting in US, Europe, and Asia datacenters
Logo
Reseller Hosting
Create your new income stream today with a reseller account
Logo
VPS (Virtual Private Server)
Fast and Affordable VPS services - Instantly Deployed
Logo
Dedicated Servers
Bare-metal servers, ideal for the performance-demanding use case.
Logo

Leave a comment

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