nginx部署
windows
location / {
root D:\\nginx-1.24.0\\html\\dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9001;
}

Linux
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
cd /usr/local
mkdir nginx
cd nginx
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -zxvf nginx-1.13.7.tar.gz
cd nginx-1.13.7
./configure --with-http_ssl_module

# 编译flv模块
# ./configure --add-module=../nginx-http-flv-module-master --with-http_ssl_module --with-http_ssl_module --with-http_xslt_module --with-http_flv_module --with-debug --with-http_gzip_static_module --with-http_auth_request_module
vi objs/Makefile
# 编译 报错可能:打开objs/Makefile 删除werror
make
make install

yum -y install gcc automake autoconf libtool make

cd /usr/local/nginx/conf
vi nginx.conf
# 启动
./usr/local/nginx/sbin/nginx
# 查看
./nginx -v
./nginx -V
[root@ecm-8c53-0001 sbin]# ./nginx -V
nginx version: nginx/1.16.1
built by gcc 8.5.0 20210514 (Anolis 8.5.0-22.0.1) (GCC)
built with OpenSSL 1.1.1k FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --user=nginx --prefix=/usr/local/nginx --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --without-http_rewrite_module
# 重新加载
./usr/local/nginx/sbin/nginx -s reload
配置nginx.conf
server {
listen 9001;
server_name localhost;
root /usr/local/xxx/dist;
location / {
index /index.html;
try_files $uri $uri/ /index.html;
}
}
443证书配置
https://help.aliyun.com/zh/ssl-certificate/user-guide/install-ssl-certificates-on-nginx-servers-or-tengine-servers?spm=a2c4g.11186623.0.0.62363359oJSo7Z
报错
checking for C compiler

yum -y install gcc
yum -y install make zlib-devel gcc-c++ libtool openssl openssl-devel
可能没联网--配置代理
vi /etc/yum.conf
proxy=http://XXX.XXX.XX.XXX:3128
-----------------------------------------------------------------------

sudo yum install pcre pcre-devel

yum -y install openssl openssl-devel
---------------------------------------------------------
./configure ok 才能 make + make install
--------------------------------------------------------


启动失败 nginx: [emerg] getpwnam("nginx") failed
[root@ecm-8c53-0001 sbin]# ./nginx
nginx: [emerg] getpwnam("nginx") failed

useradd -M -s /sbin/nologin nginx
浙公网安备 33010602011771号