nginx分为核心模块,基础模块,第三方模块 handlers,filters,proxies worker_processes 开启的进程数,一般和CPU个数相同就行 debug, info,notice,warn,error,crit worker_connections 每个进程的最大连接数 keepalive_timeout nginx -V 查看编译的模块 gzip_vary 可以让前端的缓存服务器缓存经过压缩的页面 gzip_comp_level 压缩的等级 upstream ip_hash down weight max_fails fail_timeout backup 要使用fair算法,必须编译upsream_fair模块 要使用url_hash轮询算法,必须编译hash charset utf8; location ~ .*.(jpg|png)
host; proxy_set_header X-Real-IP
proxy_add_x_forwarded_for; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; //// //图片防盗链
image.png
//日志分割脚本
image.png
//////nginx性能优化
1、编译nginx之前修改模式,取消debug模式
auto/cc/gcc 文件下删除 CFLAGS="$CFLAGS -g"
2、为特定CPU编译
image.png
3、利用TCMalloc优化nginx性能
image.png
image.png
4、服务器内核参数优化
image.png
PHP模块,需要安装PHP-FPM
image.png
nginx针对PHP模块优化,开启缓存
image.png
//nginx+perl,需要安装fcgi模块
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有