Boela kwa blog
Ferikgong 13, 2026Dikaelo

Jang go Tsenya le go Beakanya Nginx mo Linux Server

Kaelo ya kgato ka kgato ya go tsenya le go beakanya Nginx web server mo di-distribution tsa Ubuntu le CentOS Linux.

Jang go Tsenya le go Beakanya Nginx mo Linux Server

Nginx ke web server e e nang le tiragatso e e kwa godimo le reverse proxy server. E itsege ka go nitama, dikarolo tse di humileng, le tshebediso e e kwa tlase ya disebediswa. Kaelo e e tla go thusa go tsenya le go beakanya Nginx mo Hiddence Linux server ya gago.

Go Tsenya Nginx mo Ubuntu/Debian

Ntšhwafatsa lenaane la di-package mme o tsenye Nginx:

bash
sudo apt update
sudo apt install nginx -y

Go Tsenya Nginx mo RHEL / CentOS / AlmaLinux / Rocky Linux

Tsenya EPEL repository le Nginx:

bash
sudo yum install epel-release -y
sudo yum install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

Peakanyo ya Motheo

Difayele tsa peakanyo tsa Nginx di kwa /etc/nginx/. Fayele e kgolo ya peakanyo ke nginx.conf. Mo Ubuntu/Debian, di-server block di kwa /etc/nginx/sites-available/, mo di-system tse di ikaegileng ka RHEL di kwa /etc/nginx/conf.d/. Testa peakanyo mme o reload:

bash
sudo nginx -t
sudo systemctl reload nginx

Go Beakanya Virtual Host

Tlhama server block ya domain ya gago:

bash
sudo nano /etc/nginx/sites-available/yourdomain.com
# Tsenya peakanyo ya server block
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Beakanya Firewall

Letlelela traffic ya HTTP le HTTPS:

bash
sudo ufw allow 'Nginx Full'
# Kgotsa ya firewalld:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Dikeletso tse di Mosola

  • Testa peakanyo ka gale pele ga o reload: sudo nginx -t
  • Tlhola di-error log tsa Nginx: sudo tail -f /var/log/nginx/error.log
  • Dirisa di-server block tsa di-website tse di mmalwa mo server e le nngwe
  • Letlelela Gzip compression go na le tiragatso e e botoka
  • Beakanya SSL certificates tsa HTTPS (bona kaelo ya rona ya SSL)