How to Install Nginx on AlmaLinux: Step-by-Step Guide 2026
So I was using Apache before and honestly it sucked. My server was always slow and I kept hearing people say “just use Nginx bro, it’s so fast”. I was like whatever, but then I tried it and man, the difference is crazy. So basically I’m gonna tell you exactly what I did when I installed it. No BS, just real stuff.
Why I Even Switched
Apache was being annoying. Like every time someone visited my site, it would just tank. I was getting tired of it. Then like three different people told me to switch to Nginx, so I was like okay fine, let’s do it. Turns out they were right.
Nginx just handles way more people at the same time without freaking out. Plus AlmaLinux is basically just free RedHat, so I don’t gotta pay for anything. Win win.
Alright Let’s Do This
First thing I made sure I could use sudo. You need that or you’re not gonna get anywhere. Then I updated my system because I learned the hard way that old stuff breaks things.
bash
sudo dnf update -y
Just ran that and went to grab some coffee while it did its thing. Took a few minutes.
Installing Nginx is Actually Super Easy
Like seriously, it’s just one command:
bash
sudo dnf install nginx -y
Done. It downloads and installs everything. I was expecting it to be complicated but nope, that’s literally it.
Starting It Up
So I ran:
bash
sudo systemctl start nginx
And it started. Cool. But here’s the thing I did wrong I didn’t make it auto-start after I rebooted. So like a week later my server restarts for some reason and suddenly Nginx is down. I’m freaking out like “what happened??” and I realized I never told it to turn on automatically.
So do this:
bash
sudo systemctl enable nginx
Then it’ll start by itself every time your server boots up. Do both commands or you’ll be mad at yourself later.
Testing If It Works
I just wanted to see if it was actually running so I did:
bash
sudo systemctl status nginx
It said active so I was like okay good. Then I went to my server’s IP address in my browser and boom there’s the Nginx welcome page.
Need your IP? Just do:
bash
hostname -I
Copy that into your browser and you should see the Nginx page if it’s working.
The Firewall Thing
Okay so I got everything working, but then I couldn’t actually access my site from my computer. I was like “wtf why isn’t this working??” Turns out AlmaLinux has a firewall on by default that was blocking everything. I totally forgot about it.
I had to tell it to let people through on the normal web ports:
bash
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
After I did that, boom, it worked. Yeah I should’ve remembered that but whatever.
Top Common Issues During Installation
Yeah so this part is important. You’re probably gonna run into some of these.
Apache Was Still Using Port 80
So I tried to start Nginx and it was like “nope, can’t do it”. I ran this to see what was using the port:
bash
sudo netstat -tlnp | grep :80
Apache was still sitting there from before. So I killed it:
bash
sudo systemctl stop httpd
And then made sure it wouldn’t start again:
bash
sudo systemctl disable httpd
After that Nginx started fine.
I Messed Up The Config File
I edited the Nginx config and made typos. When I tried to restart it, nothing happened and I had no idea what was wrong. Then I found this thing:
bash
sudo nginx -t
This checks if your config is broken. It would’ve told me I messed up. Now I always run this before restarting so I don’t waste time.
Files Wouldn’t Load
When I tried to use my own files, Nginx kept saying it couldn’t access them. Turns out Nginx runs as a user called “nginx” and it didn’t have permission to read my stuff.
So I did this:
bash
sudo chown -R nginx:nginx /var/www/your-directory
And boom, fixed. Nginx could now read the files.
SSL Certificate Won’t Load
I was trying to set up HTTPS with a self-signed cert and kept getting errors about “unable to read private key”. Turned out the cert files didn’t have the right permissions either. Nginx couldn’t read them because they were owned by root. I had to do:
bash
sudo chmod 644 /path/to/cert.crt
sudo chmod 600 /path/to/private.key
That fixed it. Yeah SSL stuff always confuses me a bit.
Nginx Eating All The RAM
After like a week of running, Nginx was using way too much memory and my server was getting slow. I checked the logs and saw like hundreds of Nginx processes running. Turns out I had a bad config that was spawning worker processes like crazy. I fixed the worker_processes setting and worker_connections in the config file and it went back to normal.
502 Bad Gateway Error
I was trying to proxy to an app running on localhost:3000, but I kept getting 502 errors. Turned out my Node app crashed and wasn’t actually running. I started it back up and the error went away. But it was annoying because I thought it was an Nginx problem when it wasn’t.
Logs Directory Filled Up Disk
My server ran out of space and everything stopped working. Turned out the Nginx access logs grew to like 20GB because I wasn’t rotating them. I had to delete the old logs and set up log rotation. That was a dumb mistake that taught me something important.
bash
sudo logrotate -f /etc/logrotate.d/nginx
Port 443 Not Working
I set up HTTPS but port 443 was still blocked by the firewall. I forgot to add it:
bash
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Took me like 2 hours to figure that out. I was checking the config over and over thinking I messed something up when it was just the firewall again.
Can’t Write To Folder
I was trying to make Nginx write files to a folder (for like uploads or something) but it couldn’t. The permissions were set wrong again. I had to make sure the folder was writable by Nginx:
bash
sudo chmod 755 /var/www/uploads
sudo chown nginx:nginx /var/www/uploads
Now Nginx can actually create files in there.
Connection Timeout Issues
Some requests were timing out randomly. Turns out the default timeout settings were too short for my app. I added this to my Nginx config:
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
That gave it more time to handle slower connections.
Nginx Won’t Restart After Config Change
I made a small config change and when I tried to restart Nginx, it just sat there doing nothing. The systemctl command hung. I had to kill the old Nginx process first:
bash
sudo pkill -9 nginx
sudo systemctl start nginx
That forced it to stop and start fresh. Kinda annoying but it worked.
Actually Making It Do Something
The main config is at /etc/nginx/nginx.conf. Don’t worry about all the stuff in there, most of it you can just leave alone.
If you wanna like proxy traffic to something else, here’s what I use. Say you got a Node app running on port 3000:
server {
listen 80;
server_name your-domain.com www.your-domain.com;
location / {
proxy_pass http://localhost:3000;
}
}
Just tell Nginx to listen on port 80 and send everything to your app. When this worked the first time I was like “oh damn I actually did it”.
Commands I Use
These are the actual commands I run all the time now:
bash
# Restart Nginx
sudo systemctl restart nginx
# Reload without kicking people off
sudo systemctl reload nginx
# Check if config is okay
sudo nginx -t
# What version you got
nginx -v
# Turn it off
sudo systemctl stop nginx
The reload thing is sick because people don’t get disconnected when you make changes. That’s pretty cool.
Make It Go Faster
After I got it all working, I wanted to make it faster. I found that if you set the worker processes to match your CPU cores it gets noticeably faster.
bash
nproc
That tells you how many cores you got. Then go edit /etc/nginx/nginx.conf and change worker_processes to that number. It’s a small thing but it actually helps.
That’s It
Installing Nginx is easier than I thought. The stuff that got me was like being dumb and forgetting the firewall, or forgetting to enable autostart, or permissions. But those are just things you learn by doing it.
If something breaks, look at /var/log/nginx/error.log. It usually tells you what went wrong. Don’t stress about it. Just try it. Yeah I made mistakes but I didn’t break anything that I couldn’t fix. Now I got a web server that just works and doesn’t give me headaches. That’s my whole story basically.
