安装依赖
yum install –y gcc pcre pcre–devel zlib zlib–devel openssl openssl–devel
下载安装包
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
执行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
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
[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=multi–user.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 list–units —type=service (查看所有已启动的服务)
原文地址:https://blog.csdn.net/kuui_chiu/article/details/130868044
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_40772.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!