Linux安装Nginx 部署静态网页

安装

直接看官网
不同Linux版本操作不一样。
https://nginx.org/en/linux_packages.html

直接看官网https://nginx.org/en/linux_packages.html#Ubuntu

照着复制粘贴就行。

简单部署使用

然后nginx -V一下,看看各种参数的配置。

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

可以看到已经搞好了。
各个参数的意义可以看Nginx的官方文档,都很详细。

由于Nginx的所有配置,都是跟nginx.conf的修改有关的,所以你找一下这个文件。可以仔细阅读文档

文档: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.

我自己在/etc/nginx/找到的。然后添加一下打包好的静态网站。转一下文档内容,就是在nginx.conf的server中添加location

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

然后Nginx reload一下就行了。

猜你喜欢

转载自blog.csdn.net/Yonggie/article/details/131718084