To install and set up Nginx on Debian Linux 9, you will need to have root privileges or access to a user with sudo privileges.
sudo apt update
sudo apt install nginx
systemctl status nginx
systemctl enable nginx
You should see the default Nginx welcome page.
The main configuration file for Nginx is located at /etc/nginx/nginx.conf. You can edit this file to customize the behavior of Nginx. For example, you can change the port that Nginx listens on, enable SSL/TLS encryption, or set up virtual hosts.
To create a virtual host, create a new configuration file in the /etc/nginx/sites-available directory. For example:
sudo vi /etc/nginx/sites-available/example.com
In the configuration file, specify the server name, document root, and any other options that you want to use. For example:
server { listen 80; server_name example.com www.example.com; root /var/www/example.com; index index.html index.htm; }
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
nginx -t
If the configuration is valid, you should see a message saying "syntax is ok" and "configuration is ok".
systemctl reload nginx
That's it! Nginx should now be installed and set up on your Debian Linux 9 system. You can use it to serve web content and set up virtual hosts.