Install Nginx on Linux to deploy static web pages

Install

Look directly at the official
website . Different Linux versions operate differently.
https://nginx.org/en/linux_packages.html

Look directly at the official website https://nginx.org/en/linux_packages.html#Ubuntu

Just copy and paste.

Simple deployment and use

Then nginx -Vlook at the configuration of various parameters.

sudo nginx -V

nginx version: nginx/1.24.0
built by gcc 9.3.0 (Ubuntu 9.3.0-10ubuntu2) 
built with OpenSSL 1.1.1f  31 Mar 2020
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pi.......

You can see it's done.
The meaning of each parameter can be found in the official Nginx documentation , which is very detailed.

Since all configurations of Nginx are nginx.confrelated to the modification, you can find this file. You can read the documentation carefully

文档:By default, the configuration file is named nginx.conf and placed in the directory /usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx.

I /etc/nginx/found it myself. Then add a packaged static website. Turn the content of the document, that is, nginx.confadd in the server location:

server {
    location / {
        root /data/www;
    }
}

Then Nginx reloads it.

Guess you like

Origin blog.csdn.net/Yonggie/article/details/131718084