-
-
Notifications
You must be signed in to change notification settings - Fork 1
Linux Nginx Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to Nginx on Linux, covering Arch Linux, CachyOS, and other distributions including installation, configuration, and server blocks.
Arch/CachyOS:
# Install Nginx
sudo pacman -S nginx
# Enable service
sudo systemctl enable --now nginx
# Check status
systemctl status nginxDebian/Ubuntu:
sudo apt install nginx
sudo systemctl enable nginxFedora:
sudo dnf install nginx
sudo systemctl enable nginxTest Nginx:
# Check if running
curl http://localhost
# Or open browser
# http://localhostEdit config:
# Edit main config
sudo vim /etc/nginx/nginx.confCommon settings:
user http;
worker_processes auto;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
}
Nginx server block:
# Create server block
sudo vim /etc/nginx/sites-available/example.comAdd:
server {
listen 80;
server_name example.com;
root /srv/http/example;
index index.html;
}
Enable:
# Create symlink
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
# Test config
sudo nginx -t
# Reload
sudo systemctl reload nginxReverse proxy:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Check logs:
# Check service
systemctl status nginx
# Check logs
journalctl -u nginx
# Or error log
sudo tail -f /var/log/nginx/error.logValidate config:
# Test configuration
sudo nginx -t
# Reload if OK
sudo systemctl reload nginxThis guide covered Nginx installation, configuration, and server blocks for Arch Linux, CachyOS, and other distributions.
- Web Servers - Web server setup
- Networking - Network setup
- Nginx: https://nginx.org/
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.