nginx安装
下载地址
https://nginx.org/en/download.html
选择
把下载好的压缩包放在
解压
tar -zxf nginx-1.27.2.tar.gz
下载
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
./configure
make&&make install
这样表示安装成功
接下去启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
访问 ip
表示启动成功
修改 nginx.conf
location / {root html/dist;index index.html index.htm;try_files $uri $uri/ @router; # 需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404}location @router {rewrite ^.*$ /index.html last;}location /haotuo {alias html/haotuo/;index index.html index.htm;try_files $uri $uri/ @routerhaotuo /haotuo/index.html; # 需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404}location @routerhaotuo {rewrite ^.*$ /index.html last;}location /prod-api {proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://localhost:8080/ruoyi-admin;}location /dev-api {proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://localhost:8080/ruoyi;}
修改config后重启nginx
ps -ef|grep nginx
kill -9 24304kill -9 24305/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf