| |

LFCE 45 ๐Ÿง Web Server โ€” Nginx Installation

โฑ๏ธ Estimated read: 11 min | |

Nginx is a web server, reverse proxy, and load balancer. The installation itself is a single package manager command, but the service that results from it is not running until it is started, not reachable until the firewall permits it, and not verified until a client requests a page from it. The previous chapters covered DNS and DHCP, which provide name resolution and address assignment. This chapter covers the first of the application services those protocols support: the web server that listens on port 80 and answers HTTP requests.

The installation procedure differs between the Debian family and the RHEL family in the package manager command and the firewall tool, but the resulting service is the same. Nginx installs with a default configuration that serves a welcome page from /var/www/html, listens on port 80, and logs to /var/log/nginx/. The administrator’s task is to install the package, start and enable the service, open the firewall, and verify that the welcome page is reachable.

Key point: Installing the package does not start the service on all distributions. On Debian and Ubuntu, the apt install command starts nginx automatically. On RHEL and its derivatives, the service must be started explicitly with systemctl start nginx. In both cases, the service must be enabled to start at boot, and the firewall must permit HTTP traffic before a remote client can reach the default page.


Why installation requires distribution-specific steps

The package-name problem.

The nginx package is named nginx on both families, but the repository that provides it differs. On Debian and Ubuntu, the package is in the default apt repositories. On RHEL, Rocky Linux, and Fedora, the package is available in the AppStream repository, but the official nginx repository provides newer versions and is the recommended source when a specific version is required . The installation command is apt install nginx on Debian and dnf install nginx on RHEL.

The firewall problem.

Debian and Ubuntu commonly use ufw, which provides application profiles. The command ufw allow 'Nginx HTTP' opens port 80 using the profile that the nginx package installs . RHEL and its derivatives use firewalld, which does not have an nginx-specific profile but provides the http service definition. The command firewall-cmd --permanent --add-service=http opens port 80, and firewall-cmd --reload applies the change .

The service-start problem.

The Debian package starts the service automatically after installation. The RHEL package does not; the service remains stopped until systemctl start nginx is run. The systemctl enable nginx command is separate from the start command and controls whether the service starts at boot. On modern systemd systems, systemctl enable --now nginx combines both operations .


a. Installing on Debian and Ubuntu

The default repositories contain a stable nginx package. The installation is two commands: update the package index, then install the package.

# Update the package index
sudo apt update

# Install nginx from the default repository
sudo apt install nginx -y

# Verify the installed version
nginx -v
# Output: nginx version: nginx/1.24.0 (Ubuntu)

The -y flag accepts the installation prompt automatically. The version that is installed depends on the distribution release; Ubuntu 24.04 provides nginx 1.24.0 . After installation, the service is started automatically by the package’s post-installation script. The systemctl status nginx command confirms that it is running.

The official nginx repository provides newer versions than the distribution’s default repository. Adding it requires importing the signing key, adding the repository, and pinning the nginx packages to prefer the official source . This is optional for a basic installation but necessary when a specific version or the mainline branch is required.


b. Installing on RHEL and its derivatives

The AppStream repository provides an nginx package, but the official nginx repository is the recommended source for the current stable version. The repository configuration is a single file that points to nginx.org.

# Create the nginx repository file
sudo tee /etc/yum.repos.d/nginx.repo <<'EOF'
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF

# Install nginx
sudo dnf install nginx -y

# Start and enable the service
sudo systemctl start nginx
sudo systemctl enable nginx

The module_hotfixes=true line is required on RHEL 8 and later because the nginx packages are built against a different module stream than the default AppStream packages . Without it, the installation may fail with a module conflict.

The service does not start automatically on RHEL. The systemctl start nginx command starts it, and systemctl enable nginx configures it to start at boot. The combined form systemctl enable --now nginx performs both operations in one command .


c. Opening the firewall and verifying the service

The firewall must permit HTTP traffic before a remote client can reach the default page. The command differs between ufw and firewalld.

# Debian/Ubuntu with ufw
sudo ufw allow 'Nginx HTTP'
sudo ufw status

# RHEL/Rocky with firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

The ufw allow 'Nginx HTTP' command uses the application profile that the nginx package installs. It opens port 80 for both IPv4 and IPv6 . The firewall-cmd commands open the http and https services permanently and reload the firewall to apply the changes .

Verification has two parts: confirming that the service is listening on port 80, and confirming that a client can retrieve the default page.

# Confirm nginx is listening on port 80
sudo ss -antpl | grep nginx
# Output: LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=...))

# Test locally with curl
curl -I http://localhost
# Output: HTTP/1.1 200 OK
#         Server: nginx/1.24.0 (Ubuntu)

The ss command confirms that the nginx process has bound to port 80. The curl -I command retrieves the HTTP headers from the local server and confirms that it returns 200 OK. A browser request to the server’s IP address returns the default “Welcome to nginx!” page .


Complete Example Session

# ============================================
# PART 1: UPDATE THE PACKAGE INDEX (DEBIAN)
# ============================================
sudo apt update

# ============================================
# PART 2: INSTALL NGINX
# ============================================
sudo apt install nginx -y

# ============================================
# PART 3: VERIFY THE INSTALLED VERSION
# ============================================
nginx -v
# Output: nginx version: nginx/1.24.0 (Ubuntu)

# ============================================
# PART 4: CHECK THE SERVICE STATUS
# ============================================
sudo systemctl status nginx
# The Debian package starts the service automatically
# Output should show "active (running)"

# ============================================
# PART 5: ENABLE THE SERVICE AT BOOT
# ============================================
sudo systemctl enable nginx

# ============================================
# PART 6: OPEN THE FIREWALL (UFW)
# ============================================
sudo ufw allow 'Nginx HTTP'
sudo ufw status
# Output includes: Nginx HTTP ALLOW Anywhere

# ============================================
# PART 7: CONFIRM THE LISTENING PORT
# ============================================
sudo ss -antpl | grep nginx
# Output: LISTEN 0 511 0.0.0.0:80

# ============================================
# PART 8: TEST LOCALLY WITH CURL
# ============================================
curl -I http://localhost
# Output: HTTP/1.1 200 OK

# ============================================
# PART 9: TEST FROM A REMOTE CLIENT
# ============================================
# From another machine on the network:
# curl http://<server-ip>
# The default "Welcome to nginx!" page is returned

# ============================================
# PART 10: INSPECT THE DEFAULT CONFIGURATION
# ============================================
ls -l /etc/nginx/
# Output: nginx.conf, sites-available/, sites-enabled/, conf.d/
cat /etc/nginx/sites-enabled/default
# The default server block listens on port 80 and serves /var/www/html

The ten parts demonstrate the complete installation and verification workflow: package update, installation, version check, service status, boot enablement, firewall opening, port verification, local test, remote test, and configuration inspection. The critical verification steps are Parts 7 and 8: the service must be listening, and it must return a successful HTTP response.


Quick Reference

Installation Commands

DistributionInstall CommandService Start
Debian / Ubuntuapt install nginxAutomatic
RHEL / Rocky / Fedoradnf install nginxsystemctl start nginx

Firewall Commands

FirewallOpen HTTPApply
ufwufw allow 'Nginx HTTP'Automatic
firewalldfirewall-cmd --permanent --add-service=httpfirewall-cmd --reload

Service Management

CommandPurpose
systemctl start nginxStart the service
systemctl enable nginxStart at boot
systemctl enable --now nginxStart and enable in one command
systemctl status nginxCheck service state
systemctl reload nginxRe-read configuration without dropping connections

Verification Commands

CommandPurpose
nginx -vShow installed version
ss -antpl | grep nginxConfirm listening on port 80
curl -I http://localhostTest local HTTP response
ls /etc/nginx/Inspect configuration directory

Best Practices

โœ… Do This:

# Update the package index before installing
apt update                                                     # โœ…

# Enable the service at boot
systemctl enable nginx                                         # โœ…

# Open the firewall for HTTP
ufw allow 'Nginx HTTP'                                         # โœ…

# Verify the service is listening on port 80
ss -antpl | grep nginx                                         # โœ…

# Test with curl before testing from a remote client
curl -I http://localhost                                       # โœ…

# Use the official nginx repository on RHEL for current versions
# The repository file with module_hotfixes=true is required      # โœ…

โŒ Don’t Do This:

# Assume the service is running after installation on RHEL
# The RHEL package does not start the service automatically      # โŒ

# Forget to reload the firewall after adding the service
firewall-cmd --permanent --add-service=http    # Not active until reload # โŒ

# Test only from the local host
# A local curl succeeds even if the firewall blocks remote access # โŒ

# Install from a third-party repository without checking the GPG key
# Verify the nginx signing key fingerprint                       # โŒ

# Use reload when a restart is required
# reload does not apply changes that require a new process       # โŒ

Common Pitfalls

PitfallWhy It HappensFix
Remote client cannot reach the serverFirewall does not permit HTTPOpen port 80 with ufw or firewall-cmd
Service not running after install on RHELRHEL package does not auto-startsystemctl start nginx
Service does not start at bootNot enabledsystemctl enable nginx
Port 80 already in useAnother web server is runningss -antpl | grep :80 to identify
RHEL installation fails with module conflictmodule_hotfixes missing from repo fileAdd module_hotfixes=true
nginx -t fails after configuration changeSyntax error in confignginx -t reports the file and line

Real-World Examples

1. Debian installation

sudo apt update && sudo apt install nginx -y

2. RHEL installation from official repo

sudo tee /etc/yum.repos.d/nginx.repo <<'EOF'
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF
sudo dnf install nginx -y

3. Start and enable

sudo systemctl enable --now nginx

4. Open ufw

sudo ufw allow 'Nginx HTTP'

5. Open firewalld

sudo firewall-cmd --permanent --add-service=http && sudo firewall-cmd --reload

6. Check listening port

sudo ss -antpl | grep nginx

7. Test locally

curl -I http://localhost

8. Check version

nginx -v

9. Check service status

systemctl status nginx

10. Inspect default site

cat /etc/nginx/sites-enabled/default

Visual

Installation Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  FROM PACKAGE TO REACHABLE WEB SERVER                        โ”‚
โ”‚                                                              โ”‚
โ”‚  Step 1: Install                                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ apt install nginx    (Debian)                          โ”‚  โ”‚
โ”‚  โ”‚ dnf install nginx    (RHEL)                            โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                           โ”‚                                  โ”‚
โ”‚                           โ–ผ                                  โ”‚
โ”‚  Step 2: Start                                               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ Debian: automatic                                      โ”‚  โ”‚
โ”‚  โ”‚ RHEL:   systemctl start nginx                          โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                           โ”‚                                  โ”‚
โ”‚                           โ–ผ                                  โ”‚
โ”‚  Step 3: Enable at boot                                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ systemctl enable nginx                                 โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                           โ”‚                                  โ”‚
โ”‚                           โ–ผ                                  โ”‚
โ”‚  Step 4: Open firewall                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ ufw allow 'Nginx HTTP'                                 โ”‚  โ”‚
โ”‚  โ”‚ firewall-cmd --add-service=http --permanent            โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                           โ”‚                                  โ”‚
โ”‚                           โ–ผ                                  โ”‚
โ”‚  Step 5: Verify                                              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ ss -antpl | grep nginx  โ†’ listening on :80             โ”‚  โ”‚
โ”‚  โ”‚ curl -I http://localhost โ†’ 200 OK                      โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Default Directory Layout

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  WHERE NGINX KEEPS ITS FILES                                 โ”‚
โ”‚                                                              โ”‚
โ”‚  /etc/nginx/                                                 โ”‚
โ”‚  โ”œโ”€โ”€ nginx.conf              โ† Main configuration            โ”‚
โ”‚  โ”œโ”€โ”€ sites-available/        โ† All server block configs      โ”‚
โ”‚  โ”œโ”€โ”€ sites-enabled/          โ† Symlinks to active configs    โ”‚
โ”‚  โ””โ”€โ”€ conf.d/                 โ† Additional config snippets    โ”‚
โ”‚                                                              โ”‚
โ”‚  /var/www/html/              โ† Default web content           โ”‚
โ”‚  โ””โ”€โ”€ index.nginx-debian.html โ† Default welcome page         โ”‚
โ”‚                                                              โ”‚
โ”‚  /var/log/nginx/                                             โ”‚
โ”‚  โ”œโ”€โ”€ access.log              โ† Request log                   โ”‚
โ”‚  โ””โ”€โ”€ error.log               โ† Error log                     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Firewall Comparison

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  DEBIAN/UBUNTU vs RHEL/ROCKY                                 โ”‚
โ”‚                                                              โ”‚
โ”‚  ufw (Debian/Ubuntu):                                        โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ ufw allow 'Nginx HTTP'                                 โ”‚  โ”‚
โ”‚  โ”‚ โ†’ Uses application profile installed by nginx package  โ”‚  โ”‚
โ”‚  โ”‚ โ†’ Opens port 80 for IPv4 and IPv6                      โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                              โ”‚
โ”‚  firewalld (RHEL/Rocky):                                     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ firewall-cmd --permanent --add-service=http            โ”‚  โ”‚
โ”‚  โ”‚ firewall-cmd --reload                                  โ”‚  โ”‚
โ”‚  โ”‚ โ†’ Uses predefined http service                         โ”‚  โ”‚
โ”‚  โ”‚ โ†’ Opens port 80                                        โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

ItemValue
Debian packagenginx (default repository)
RHEL packagenginx (AppStream or official repository)
Debian service startAutomatic on install
RHEL service startsystemctl start nginx
Boot enablementsystemctl enable nginx
ufw HTTP ruleufw allow 'Nginx HTTP'
firewalld HTTP rulefirewall-cmd --permanent --add-service=http
Default listening port80
Default content directory/var/www/html
Main config file/etc/nginx/nginx.conf
Verificationss -antpl | grep nginx, curl -I http://localhost

Key takeaways:

  • The installation command differs by distribution. apt install nginx on Debian and Ubuntu; dnf install nginx on RHEL and its derivatives. The package name is the same, but the repository and the service-start behavior differ.
  • The service does not always start automatically. Debian starts it after installation. RHEL does not. systemctl start nginx and systemctl enable nginx are separate operations on both families .
  • The firewall must permit HTTP. Without ufw allow 'Nginx HTTP' or firewall-cmd --add-service=http, the service listens locally but remote clients cannot reach it .
  • The default page is served from /var/www/html. The sites-enabled/default file contains the server block that listens on port 80 and serves the welcome page. The configuration is already functional after installation.
  • Verification requires two checks. The ss command confirms the service is listening on port 80. The curl command confirms that it returns an HTTP response. A local test does not confirm that the firewall permits remote access; a remote test is required for that.
  • The official nginx repository provides current versions on RHEL. The repository file requires module_hotfixes=true on RHEL 8 and later to avoid module conflicts with the AppStream packages .

Remember: Nginx installation is one package command, but the service is not reachable until it is started, enabled, and permitted through the firewall. The Debian package starts the service automatically; the RHEL package does not. The ufw and firewalld commands open port 80 through different mechanisms. The default configuration serves a welcome page from /var/www/html, and the curl test confirms that the HTTP response is correct. Install, start, enable, open the firewall, and verify. The web server is ready when the remote client receives the welcome page, not when the package installation completes.


Was this helpful?


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!