Web Server Setup – Nginx
Nginx is one of the most popular web servers. With a focus on static content handling, Nginx can be more scalable and faster than other web servers. This lesson will explain how to set up Nginx for Django app deployment.
There are five steps to set up Nginx:
- Install Nginx
- Add an Nginx configuration file to sites-available
- Add a symbolic link of the configuration file to sites-enabled
- Update static file location
- Adjust firewall settings
- Check if the Django app is running
Note: For the Nginx setting, the virtual environment is not needed as it's directly installed on the OS.
Install Nginx
Install Nginx using the apt-get
command.
sudo apt-get update
sudo apt-get install -y nginx
As Nginx runs when it is installed, check if it is running by the systemctl status
command.
systemctl status nginx
Unless you encounter an issue, you'll see the message below.
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-04-21 16:05:47 UTC; 21h ago
Docs: man:nginx(8)
Process: 123945 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (cod>
:
Add an Nginx configuration file
Nginx has several co
Subscribe now for
uninterrupted access.