Nginx linux安装
官网下载地址:(.tar.gz)
https://nginx.org/en/download.html
安装linux-nginx:
1 2 3 4 5 6 7 8 | wget -c http: //nginx.org/download/nginx-1.22.0.tar.gz //下载nginx tar -zxvf nginx-1.22.0.tar.gz yum -y install gcc gcc-c++ autoconf automake make yum -y install openssl openssl-devel cd nginx-1.22.0 //配置configure --prefix 代表安装的路径,--with-http_ssl_module 安装ssl,--with-http_stub_status_module查看nginx的客户端状态 ./configure --prefix=/usr/local/nginx-1.22.0 --with-http_ssl_module --with-http_stub_status_module make & make install //编译nginx |
常用命令:
1 2 3 4 5 6 7 8 9 | ./nginx -v //查看版本 find / -name nginx.conf //nginx配置文件的位置 ps aux|grep nginx //查看服务是否已经启动 netstat -tnlp //查看端口监听状态 ./nginx -t //验证nignx配置文件是否正确 ./nginx -s reload //重启./nginx -s stop, quit, reopen, reload ./nginx -s quit //此方式停止步骤是待nginx进程处理任务完毕进行停止。 ./nginx -s stop //此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。 ./nginx //启动 |
常用配置:
1 2 3 4 | find / -name nginx.conf // 查找nginx配置 vi /usr/local/nginx-1 .22.0 /conf/nginx .conf cd /usr/local/nginx-1 .22.0 /sbin/ #启动位置 ./nginx -s reload /usr/local/nginx-1 .22.0 /logs #log日志 |
linux:配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | server { listen 80; server_name localhost; location / { root /xx/xx/dist ; index index.html index.htm; try_files $uri $uri/ @router; } location @router { rewrite ^.*$ /index .html last; } location /api/ { proxy_pass http: //127 .0.0.1:8080/; } location /files { proxy_pass http: //xxx/api ; proxy_redirect off; #重定向 proxy_set_header Host $host; #后端的Web服务器可以通过X-Forwarded-For>获取用户真实IP proxy_set_header X-Real-IP $remote_addr; #添加远程地址 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #代理地址转发 client_max_body_size 5120m; #允许客户端请求的最大单文件字节数 client_body_buffer_size 5m; #缓冲区代理缓冲用户端请求的最大字节数 proxy_connect_timeout 600; #nginx跟后端服务器连接超时时间(代理连接超时) proxy_read_timeout 600; #连接成功后,后端服务器响应时间(代理接收超时) proxy_buffer_size 2m; #设置代理服务器(nginx)保存用户头信息的缓冲区大小 proxy_buffers 3 2m; #proxy_buffers缓冲区,网页平均下载设置 proxy_busy_buffers_size 2m; #高负荷下缓冲大小proxy_buffer_size=proxy_busy_buffers_size<=proxy_buffers proxy_temp_file_write_size 2m; #设定缓存文件夹大小,大于这个值,将从upload服务器传 } } |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析