January 13, 2026Guides
How to Install and Configure Nginx on Linux Server
Step-by-step guide on installing and configuring Nginx web server on Ubuntu and CentOS Linux distributions.

Nginx is a high-performance web server and reverse proxy server. It's known for its stability, rich feature set, and low resource consumption. This guide will help you install and configure Nginx on your Hiddence Linux server.
Installing Nginx on Ubuntu/Debian
Update package list and install Nginx:
bash
sudo apt update
sudo apt install nginx -yInstalling Nginx on RHEL / CentOS / AlmaLinux / Rocky Linux
Install EPEL repository and Nginx:
bash
sudo yum install epel-release -y
sudo yum install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginxBasic Configuration
Nginx configuration files are located in /etc/nginx/. The main configuration file is nginx.conf. On Ubuntu/Debian, server blocks are in /etc/nginx/sites-available/, on RHEL-based systems in /etc/nginx/conf.d/. Test configuration and reload:
bash
sudo nginx -t
sudo systemctl reload nginxSetting Up Virtual Host
Create a server block for your domain:
bash
sudo nano /etc/nginx/sites-available/yourdomain.com
# Add server block configuration
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxConfigure Firewall
Allow HTTP and HTTPS traffic:
bash
sudo ufw allow 'Nginx Full'
# Or for firewalld:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reloadUseful Tips
- Always test configuration before reloading: sudo nginx -t
- Check Nginx error logs: sudo tail -f /var/log/nginx/error.log
- Use server blocks for multiple websites on one server
- Enable Gzip compression for better performance
- Set up SSL certificates for HTTPS (see our SSL guide)