#### 1.安装nginx解压和编译的lib库
```
# 一键安装四个依赖包
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
```
#### 2.下载nginx
> 首先进入/usr/local目录
```
# 下载nginx nginx-1.24.0压缩包
wget -c http://nginx.org/download/nginx-1.24.0.tar.gz
```
#### 3.解压
> tar -xvf 可以解压tar.xz后缀的压缩文件
> tar -zxvf 可以解压tar.gz后缀的压缩文件
```
tar -zxvf nginx-1.24.0.tar.gz
# 重命名
mv nginx-1.24.0 nginx
```
#### 4.配置、安装
```
# 执行命令 考虑到后续安装ssl证书 添加两个模块
./configure --with-http_stub_status_module --with-http_ssl_module
//执行make命令、执行make install命令
make && make install
```
#### 5.启动nginx服务
```
# 进入nginx根目录
cd /usr/local/nginx/sbin/nginx
# 执行启动命令
./nginx
# 关闭nginx
./nginx -s stop
# 重启nginx
./nginx -s reload
```
#### 6.查看nginx进程是否启动
```
ps -ef | grep nginx
```
![在这里插入图片描述](https://img-blog.csdnimg.cn/e194222b33694af799f229911afb1c6f.jpeg)
#### 7.开放防火墙
> --permanent 代表永久生效,否则重启linux后要再次开启
``` linux
# 开放80端口
firewall-cmd --add-port=80/tcp --permanent
# 重启防火墙
firewall-cmd --reload
```
> 查看防火墙端口开放状态
```
firewall-cmd --list-all
```
> ps:
```
# 开启防火墙
systemctl start firewalld
# 开放指定端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# 重启防火墙
firewall-cmd --reload
# 查看端口号
netstat -ntlp
netstat -ntulp |grep 80
# 开放端口列表
firewall-cmd --list-all
```
---
> vue项目打包部署配置:
```
location / {
root /usr/local/nginx/html/dist;
index index.html index.htm;
}
location /api/{
proxy_pass http://localhost:9527/;
}
# ureport
location /ureport/ {
proxy_pass http://localhost:8007/ureport/;
}
# 积木报表
location /jmreport/ {
proxy_pass http://localhost:8085/jmreport/;
}
```