Overview¶
This is our developer docs about Use Nginx to Web server
Install Nginx¶
- Install Nginx
sudo apt update sudo apt install nginx -y
- Adjusting the Firewall
sudo ufw enable sudo ufw allow ssh sudo ufw allow 22 sudo ufw allow 'Nginx Full'
Setting Up Server Blocks¶
- Installing PHP and Configuring Nginx to Use the PHP Processor
sudo apt install php-fpm php-mysql -y
- Config Site available nginx: /etc/nginx/sites-available/nginx-server
server { listen 80; listen [::]:80; server_name nginx.example.com; root /var/www/html; index index.php index.html index.htm index.nginx-debian.html; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.2-fpm.sock; } location ~ /\.ht { deny all; } }
- Enable new server block
sudo ln -s /etc/nginx/sites-available/nginx-server /etc/nginx/sites-enabled/
- Test new config file and reload nginx
sudo nginx -t sudo systemctl reload nginx