安装依赖
yum instally gcc pcre pcredevel zlib zlibdevel openssl openssldevel

下载安装
cd /tmp
wget http://nginx.org/download/nginx-1.23.1.tar.gz

解压
sudo tar zxvf /tmp/nginx-1.23.1.tar.gz

配置configure
cd nginx-1.23.1
sudo ./configure

修改makefile文件
sudo vi Makefile

命令前加上sudo

执行make & make install
make & make install

启动nginx
cd /usr/local/nginx/sbin
sudo ./nginx
sudo /usr/local/nginx/sbin/nginx

查看是否启动
ps aux | grep nginx
ps ef | grep nginx

关闭nginx
killall nginx

/opt/calb_report/dist

vue.config.js配置 publicPath:
publicPath: ‘/upload

设置代理
 location /upload/ {
            alias   /opt/calb_report/dist/;
            try_files $uri $uri/ /index.html;
        }

        location /api/ {
            proxy_pass http://10.112.218.173:5005;
        }

添加服务
vi /lib/systemd/system/nginx.service

nginx.service内容如下

[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true
Restart=always
# Restart service after 5 seconds if the dotnet service crashes:
RestartSec=5
KillSignal=SIGINT
SyslogIdentifier=nginx
User=root

[Install]
WantedBy=multiuser.target

sudo systemctl start nginx.service (启动nginx服务

sudo systemctl stop nginx.service (停止nginx服务

sudo systemctl enable nginx.service (设置开机自启动

sudo systemctl disable nginx.service (停止开机自启动

sudo systemctl status nginx.service (查看服务当前状态

sudo systemctl restart nginx.service (重新启动服务

sudo systemctl listunits —type=service (查看所有已启动的服务

原文地址:https://blog.csdn.net/kuui_chiu/article/details/130868044

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_40772.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注