系统部署
站点访问配置站点访问配置
以Nginx为例
1. 安装nginx
安装依赖
yum install -y readline-devel pcre-devel openssl-devel gcc
安装nginx
- 手动安装
# 解压安装包
tar zxcf openresty-$\{VERSION\}.tar.gz
# 进入nginx目录
cd openresty-$\{VERSION\}
# 配置安装目录等
./configure --prefix=/data0 --with-http_stub_status_module --with-http_addition_module
# 编译&&安装
make && make install
# 启动nginx
cd /data0/nginx/sbin
./nginx
开机启动参考官方文档
- yum安装
yum install -y nginx
2. 修改nginx配置文件
配置文件
- 编译安装:/data0/nginx/conf/nginx.conf
- yum安装:/etc/nginx/nginx.conf
参考配置(仅server部分配置)
server {
listen 80;
server_name www.swikoon.com;
# PC站配置www.swikoon.com域名访问swikoon_pc目录
location / {
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
root /www/docker/ruoyi-admin/wwwroot_release/swikoon_pc;
index index.shtml index.html index.htm;
}
location ~ ^/(images|img|fonts|assets|js|css)/ {
root /www/docker/ruoyi-admin/wwwroot_release/swikoon_pc;
expires 1d;
}
# 搜索动态模板访问代理
location = /_search {
rewrite /_search?(.*) /_search?sid=1630092239507464193&pp=pc&$1 break;
ssi on;
ssi_silent_errors on;
proxy_buffers 32 8k;
add_after_body "";
proxy_cookie_path / /;
proxy_pass http://localhost:8090;
}
# 后台上传的资源文件访问统一代理到swikoon目录,如果使用OSS不需要配置
location ~ ^/(resources)/ {
root /www/docker/ruoyi-admin/wwwroot_release/swikoon;
expires 1d;
}
}
3. 启动nginx
- 手动安装
# 进入sbin目录
cd /data0/nginx/sbin
# 检查配置文件
./nginx -t
# 重启
./nginx -s reload
- yum安装
# 检查配置文件
nginx -t
# 重启
./nginx -s reload