安装Nginx
安装
[root@iZ0s0dama8ff4xZ ~]# yum list nginx
Last metadata expiration check: 2:15:43 ago on Fri 14 Feb 2025 07:47:34 AM CST.
Available Packages
nginx.x86_64
[root@iZ0s0dama8ff4xZ ~]# yum install nginx.x86_64
# 配置文件地址
[root@iZ0s0dama8ff4xZ ~]# cd /etc/nginx/conf.d/
# simpleiot项目配置文件(这里根据你自己项目创建,我的项目名叫simpleiot)
[root@iZ0s0dama8ff4xZ conf.d]# vim simpleiot.cn.conf
server {
listen 80;
server_name simpleiot.cn;
location / {
add_header Cache-Control no-cache;
root /data/www/kmcrm/web/dist;
index index.html index.htm;
# try_files $uri $uri/;
try_files $uri $uri/ /index.html;
}
location /api/ {
rewrite ^/api/(.*)$ /$1 break;
proxy_pass 'http://127.0.0.1:6092';
}
# location /file/ {
# rewrite ^/file/(.*)$ /$1 break;
# proxy_pass 'http://127.0.0.1:8012/';
#}
#location /webroot/decision {
#proxy_pass 'http://127.0.0.1:28080/webroot/decision';
# }
location = /50x.html {
root html;
}
}
nginx 启动
# 设置 Nginx 在系统启动时自动启动
systemctl enable nginx
# 查看状态
systemctl status nginx
# 启动
systemctl start nginx
# 重启
systemctl restart nginx
# 重新加载 Nginx 配置
systemctl reload nginx