How to install Nginx Web Server on Debian 11. Install Nginx and configure Uncomplicated Firewall (ufw). Create a simple test website and basic Nginx http server block.
# update packages apt update && apt upgrade # install nginx apt install nginx # check nginx status systemctl status nginx
# check nginx version nginx -v
# add ufw firewall rules to allow http and https ufw allow 80 ufw allow 443 # check ufw status ufw status
#restart nginx service nginx restart #stop nginx service nginx stop #start nginx service nginx start #reload nginx service nginx reload
# check nginx config files nginx -t
The Nginx web server runs as user www-data on Debian
/etc/nginx/nginx.conf
The default config file that Nginx reads when the web server starts
sites-available and sites-enabled/etc/nginx/sites-available/etc/nginx/sites-enabled
sites-available contains all the website config files, sites-enabled contains live websites that are running on the web server
Web sites are enabled by creating a symbolic link to the config file in /etc/nginx/sites-enabled
sudo ln -s /etc/nginx/sites-available/yourdomain.com.conf /etc/nginx/sites-enabled/
mkdir /var/www/yourdomain.com/html -pchown -Rf www-data:www-data /var/www/yourdomain.com chmod -Rf 750 /var/www/yourdomain.com
<html>
<head>
<title>Welcome to Your Domain </title>
</head>
<body>
<h1>Nginx web server has been setup for yourdomain.com </h1>
<p>This is a test page.</p>
</body>
</html>
nano /etc/nginx/sites-available/yourdomain.com.conf
server {
listen 80;
root /var/www/yourdomain.com/html;
index index.html;
server_name yourdomain.com;
}
Link the web site config file to sites-enabledsudo ln -s /etc/nginx/sites-available/yourdomain.com.conf /etc/nginx/sites-enabled
Test the nginx confignginx -t
Reload nginxservice nginx reload
C:\Windows\System32\drivers\etc\hosts
References:
by Author
Controlling NGINX Processes at Runtime
Nginx Beginners Guide
Comments