Skip to content
Runbook

Install Nginx on Fedora / RHEL

High-performance web server, reverse proxy, load balancer and HTTP cache.

Toolweb-serverreverse-proxyload-balancerhttpproxy

Installation

Nginx (Fedora repositories) · dnf
sudo dnf install -y nginx

Verify the installation

Verify
nginx -v

Service

Start
sudo systemctl start nginx
Stop
sudo systemctl stop nginx
Status
sudo systemctl status nginx
Restart
sudo systemctl restart nginx
On boot
sudo systemctl enable nginx

Important files

TypePathDescription
config/etc/nginx/nginx.confMain configuration file.
config/etc/nginx/conf.dDirectory for additional server blocks (included by nginx.conf).
data/usr/share/nginx/htmlDefault document root.
log/var/log/nginxAccess and error logs.

Default ports

80

Command-line tools

  • nginxThe server binary; nginx -t to test, nginx -s reload to reload.

Uninstall

Uninstall
sudo systemctl stop nginx
sudo dnf remove -y nginx

Good to know

  • Fedora uses /etc/nginx/conf.d for additional server blocks (no sites-available by default).
  • Open the firewall: sudo firewall-cmd --add-service=http --permanent && sudo firewall-cmd --reload.
  • SELinux may block reverse-proxy connections: allow with sudo setsebool -P httpd_can_network_connect 1.

Installation on Fedora

sudo dnf install -y nginx installs the server. Enable and start it with sudo systemctl enable --now nginx. The document root is /usr/share/nginx/html.

Firewall and SELinux

Fedora's firewall blocks HTTP by default: open it with sudo firewall-cmd --add-service=http --permanent && sudo firewall-cmd --reload. If Nginx acts as a reverse proxy, SELinux may block outbound connections — allow them with sudo setsebool -P httpd_can_network_connect 1.

Configuration layout

Add server blocks under /etc/nginx/conf.d/*.conf (included by nginx.conf); there is no sites-available pattern by default. Validate with nginx -t, then sudo systemctl reload nginx.