In this blog, we will learn in depth how to install, configure and manage Nginx, a popular open source web server and reverse proxy server, on Debian 10. We'll cover Nginx installation, basic configuration, adding custom configuration files, and setting up automatic startup on boot.
step:
-
Updating the system:
Update the package list and installed packages with root privileges using the following command:apt update apt upgrade
-
Install Nginx:
Install Nginx with root privileges using the following command:apt install nginx
-
Start the Nginx service:
After the installation is complete, the Nginx service will start automatically. You can check the Nginx service status with the following command:systemctl status nginx
If you see "active (running)" status, Nginx is successfully installed and running.
-
Basic configuration:
The default configuration file of Nginx is located/etc/nginx
in the directory. You can configure and customize according to your needs, such as changing the website folder path or setting up virtual hosts, etc. Please refer to the official Nginx documentation for more configuration options and detailed instructions. -
Add a custom configuration file: Create a custom configuration file under the directory to add additional configuration
./etc/nginx/conf.d/
For example, create amy-website.conf
file called:nano /etc/nginx/conf.d/my-website.conf
Add your custom Nginx configuration in this file, and save the file.
-
Check the configuration:
Use the following command to check whether the Nginx configuration is correct:nginx -t
If configured correctly, it will be displayed
nginx: configuration file /etc/nginx/nginx.conf test is successful
. -
Reload Nginx:
Reload Nginx with the following command for configuration changes to take effect:systemctl reload nginx
-
Autostart at boot:
Enable Nginx to start automatically at boot with the following command:systemctl enable nginx
Conclusion:
Through this blog, you have learned the detailed steps to install, configure and manage Nginx on Debian 10. Now you can start using Nginx to host your website or application and customize and further configure it as needed.