故事背景:当我们要排查线上问题,必须上流水线构建部署,或者不能直接接触服务器及部署资源,且本地无法复现线上的状况时,可以模拟建立一个本地的线上环境,用来验证复现
一、下载免安装nginx
压缩包
http://nginx.org/en/download.html
二、博主选1.18.0
三、解压缩后
四、修改conf
目录下的nginx.conf
(根据自己的情况来)
我修改后的配置:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
keepalive_timeout 600;
client_header_timeout 600;
client_body_timeout 600;
reset_timedout_connection on;
send_timeout 600;
#gzip on;
server {
listen 8088;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /actionDimension/report/ {
proxy_pass http://33.7.105.34:8080/report/;
}
location /customerManageDimension/report/ {
proxy_pass http://33.7.105.34:8080/report/;
}
location /messageSendDimension/report/ {
proxy_pass http://33.7.105.34:8080/report/;
}
location /moonBulletinDimension/report/ {
proxy_pass http://33.7.105.34:8080/report/;
}
}
}
五、将前端打包后的dist
目录里所有文件拷贝到html
目录下
六、command+R
打开window的运行
窗口,并输入PowerShell
打开命令窗口
七、cd到nginx
的解压缩根目录
下
八、输入./nginx
运行Nginx服务
(也可以运行./nginx -s reload
重启服务)
九、nginx
运行报错conf unknown directive " "
解决方案
这是编码问题,需要用记事本另存为ANSI
编码
附上其他链接:
redis官网:https://redis.io/
windows版本免安装redis下载链接:https://github.com/MSOpenTech/redis/releases
nginx官网:http://nginx.org/
windows版本免安装redis下载链接:http://nginx.org/en/download.html
注意:
如果直接双击nginx.exe
,会导致修改配置后重启、停止nginx无效
,需要手动关闭任务管理器内的所有nginx进程
在nginx.exe
目录,打开命令行工具,用命令启动/关闭/重启nginx
如果没有设置环境变量,执行命令需要加路径./(根据自己的目录和cmd目录来确定),如果设置了PATH就可以省略
- 启动:
start ./nginx
- 重新加载配置:
./nginx -s reload
- 重新打开日志文件:
./nginx -s reopen
- 测试nginx配置文件是否正确:
./nginx -t -c conf/nginx.conf
- 关闭nginx:
./nginx -s stop
(快速停止nginx)./nginx -s quit
(有序停止nginx) - zookeeper官网:
http://zookeeper.apache.org/
- windows版本免安装zookeeper下载链接:
http://mirrors.shu.edu.cn/apache/zookeeper/stable/