Detailed steps to install and configure Nginx on Debian 10

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:

  1. Updating the system:
    Update the package list and installed packages with root privileges using the following command:

    apt update
    apt upgrade
    
  2. Install Nginx:
    Install Nginx with root privileges using the following command:

    apt install nginx
    
  3. 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.

  4. Basic configuration:
    The default configuration file of Nginx is located /etc/nginxin 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.

  5. Add a custom configuration file: Create a custom configuration file under the directory to add additional configuration
    . /etc/nginx/conf.d/For example, create a my-website.conffile called:

    nano /etc/nginx/conf.d/my-website.conf
    

    Add your custom Nginx configuration in this file, and save the file.

  6. 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.

  7. Reload Nginx:
    Reload Nginx with the following command for configuration changes to take effect:

    systemctl reload nginx
    
  8. 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.

Guess you like

Origin blog.csdn.net/qq_39997939/article/details/131349271