[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"consumer-news-detail-839":3,"consumer-news-interaction-839":40,"consumer-news-related-839":43},{"detail":4,"item":35},{"card":5,"schemaVersion":22,"fields":23,"content":29},{"id":6,"kind":7,"targetType":8,"targetId":9,"subtype":7,"typeLabel":10,"title":11,"subtitle":12,"summary":13,"coverUrl":14,"badgeText":14,"href":15,"sourceName":12,"meta":16,"metrics":19,"tags":20,"resolved":21},"NEWS_ARTICLE:839","news","NEWS_ARTICLE",839,"资讯","Nginx 1.30.4 编译安装与参数调优","博客园","Nginx 是一款轻量级、高性能、高并发的开源Web服务器、反向代理与负载均衡软件，凭借低资源占用、高稳定性的核心优势，成为当下互联网行业主流的服务部署组件，广泛应用于各类网站及业务系统的Web服务、反向代理、负载均衡场景。其基于宽松的类BSD开源协议发布，可免费商用。本文将完整展示 Nginx 1","","\u002Fnews\u002F839",[17,18],"2026","云原生与运维",{},[18],true,"consumer-content-detail-v1",{"sourceName":12,"authorName":24,"categoryName":18,"summary":13,"description":13,"publishTime":25,"updateTime":26,"sourceUrl":27,"language":28},"lyshark","2026-09-02T12:24","2026-09-02T20:37:48","https:\u002F\u002Fwww.cnblogs.com\u002FLyShark\u002Fp\u002F22803646","中文",{"format":30,"policy":31,"normalized":21,"html":32,"text":33,"wordCount":34,"hasBody":21},"HTML","NEWS_CONTENT_V1","\u003Cp>Nginx 是一款轻量级、高性能、高并发的开源Web服务器、反向代理与负载均衡软件，凭借低资源占用、高稳定性的核心优势，成为当下互联网行业主流的服务部署组件，广泛应用于各类网站及业务系统的Web服务、反向代理、负载均衡场景。其基于宽松的类BSD开源协议发布，可免费商用。本文将完整展示 Nginx 1.30.4 源码编译安装、环境配置、systemd服务管理、内核及配置高性能调优的全套流程，适配CentOS\u002FRHEL 10系列系统，可直接落地应用于企业生产环境。\u003C\u002Fp>\n\u003Cp>1、源码编译需要gcc编译工具、正则、加密、压缩等依赖库，先执行依赖安装命令，确保编译环境完整。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# dnf install -y epel-release\n[root@localhost ~]# dnf install -y gcc gcc-c++ make zlib zlib-devel pcre2 pcre2-devel openssl openssl-devel libtool\nLast metadata expiration check: 0:25:59 ago on Wed 02 Sep 2026 10:03:21 AM CST.\nPackage gcc-14.4.1-3.el10.x86_64 is already installed.\nPackage gcc-c++-14.4.1-3.el10.x86_64 is already installed.\nPackage make-1:4.4.1-9.el10.x86_64 is already installed.\nPackage zlib-ng-compat-2.2.3-3.el10.x86_64 is already installed.\nPackage zlib-ng-compat-devel-2.2.3-3.el10.x86_64 is already installed.\nPackage pcre2-10.44-1.el10.3.x86_64 is already installed.\nPackage pcre2-devel-10.44-1.el10.3.x86_64 is already installed.\nPackage openssl-1:3.5.8-1.el10.x86_64 is already installed.\nPackage openssl-devel-1:3.5.8-1.el10.x86_64 is already installed.\nPackage libtool-2.4.7-14.el10.x86_64 is already installed.\nDependencies resolved.\nNothing to do.\nComplete!\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>2、从Nginx官方镜像下载稳定版1.30.4源码包，解压后进入源码目录，为编译做准备。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# wget https:\u002F\u002Fnginx.org\u002Fdownload\u002Fnginx-1.30.4.tar.gz\n[root@localhost ~]# tar -xzvf nginx-1.30.4.tar.gz\n[root@localhost nginx-1.30.4]# ls -lh\ntotal 916K\ndrwxr-xr-x 6 502 wheel 4.0K Sep  2 10:28 auto\n-rw-r--r-- 1 502 wheel 338K Jul 16 01:24 CHANGES\n-rw-r--r-- 1 502 wheel 517K Jul 16 01:24 CHANGES.ru\n-rw-r--r-- 1 502 wheel 5.1K Jul 16 01:20 CODE_OF_CONDUCT.md\ndrwxr-xr-x 2 502 wheel  168 Sep  2 10:28 conf\n-rwxr-xr-x 1 502 wheel 2.6K Jul 16 01:20 configure\ndrwxr-xr-x 4 502 wheel   72 Sep  2 10:28 contrib\n-rw-r--r-- 1 502 wheel 4.9K Jul 16 01:20 CONTRIBUTING.md\ndrwxr-xr-x 2 502 wheel   40 Sep  2 10:28 html\n-rw-r--r-- 1 502 wheel 1.3K Jul 16 01:20 LICENSE\ndrwxr-xr-x 2 502 wheel   21 Sep  2 10:28 man\n-rw-r--r-- 1 502 wheel  15K Jul 16 01:20 README.md\n-rw-r--r-- 1 502 wheel 4.8K Jul 16 01:20 SECURITY.md\ndrwxr-xr-x 9 502 wheel   91 Jul 16 01:20 src\n-rw-r--r-- 1 502 wheel 1.7K Jul 16 01:20 SUPPORT.md\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>3、为保证服务安全，创建不可登录系统用户运行Nginx，同时创建临时文件目录、日志存储目录，规范文件管理。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# useradd -s \u002Fsbin\u002Fnologin nginx\n[root@localhost ~]# mkdir -p \u002Fvar\u002Ftmp\u002Fnginx\n[root@localhost ~]# mkdir -p \u002Fvar\u002Flog\u002Fnginx\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>4、自定义Nginx安装路径、日志路径、进程文件路径，同时开启SSL、状态监控、反向代理、流媒体等核心常用模块，适配绝大多数生产场景。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost nginx-1.30.4]# mkdir -p \u002Fusr\u002Flocal\u002Fnginx\n[root@localhost nginx-1.30.4]# .\u002Fconfigure \\\n--user=nginx \\\n--group=nginx \\\n--prefix=\u002Fusr\u002Flocal\u002Fnginx \\\n--sbin-path=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx \\\n--conf-path=\u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf \\\n--error-log-path=\u002Fvar\u002Flog\u002Fnginx\u002Ferror.log \\\n--http-log-path=\u002Fvar\u002Flog\u002Fnginx\u002Faccess.log \\\n--pid-path=\u002Fvar\u002Frun\u002Fnginx.pid \\\n--lock-path=\u002Fvar\u002Frun\u002Fnginx.lock \\\n--http-client-body-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Fclient_body \\\n--http-proxy-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Fproxy \\\n--http-fastcgi-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Ffastcgi \\\n--http-uwsgi-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Fuwsgi \\\n--http-scgi-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Fscgi \\\n--with-http_ssl_module \\\n--with-http_stub_status_module \\\n--with-http_realip_module \\\n--with-http_sub_module \\\n--with-http_addition_module \\\n--with-http_random_index_module \\\n--with-http_secure_link_module \\\n--with-http_gunzip_module \\\n--with-http_gzip_static_module \\\n--with-stream \\\n--with-stream_ssl_module\n\n[root@localhost nginx-1.30.4]# make\n[root@localhost nginx-1.30.4]# make install\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>默认Nginx会暴露版本号，存在一定安全风险，可通过修改源码文件隐藏版本信息（本文仅展示配置，按需修改）。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# vim nginx-1.30.4\u002Fsrc\u002Fcore\u002Fnginx.h\n\n#define nginx_version      1030004\n#define NGINX_VERSION      \"1.30.4\"\n#define NGINX_VER          \"nginx\u002F\" NGINX_VERSION\n\n#ifdef NGX_BUILD\n#define NGINX_VER_BUILD    NGINX_VER \" (\" NGX_BUILD \")\"\n#else\n#define NGINX_VER_BUILD    NGINX_VER\n#endif\n\n#define NGINX_VAR          \"NGINX\"\n#define NGX_OLDPID_EXT     \".oldbin\"\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>5、通过版本命令验证安装是否成功，确认编译参数、依赖版本无误。输出包含Nginx版本、GCC编译版本、OpenSSL版本及已开启的模块，即代表编译安装成功。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost nginx-1.30.4]# cd \n[root@localhost ~]# \u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx -V\nnginx version: nginx\u002F1.30.4\nbuilt by gcc 14.4.1 20260724 (Red Hat 14.4.1-3) (GCC) \nbuilt with OpenSSL 3.5.8 25 Aug 2026\nTLS SNI support enabled\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>6、为方便全局调用nginx命令，将程序路径加入系统环境变量。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# echo 'export PATH=$PATH:\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin' &gt;&gt; \u002Fetc\u002Fprofile\n[root@localhost ~]# source \u002Fetc\u002Fprofile\n[root@localhost ~]# nginx -v\nnginx version: nginx\u002F1.30.4\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>7、创建systemd服务文件，实现Nginx开机自启、启停、重载管理，适配系统服务管理规范。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# vim \u002Fusr\u002Flib\u002Fsystemd\u002Fsystem\u002Fnginx.service\n\n[Unit]\nDescription=nginx\nAfter=network.target\n[Service]\nType=forking\nExecStart=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx\nExecReload=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx -s reload\nExecStop=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx -s stop\n[Install]\nWantedBy=multi-user.target\n\n[root@localhost ~]# systemctl daemon-reload\n[root@localhost ~]# systemctl start nginx\n[root@localhost ~]# systemctl status nginx\n● nginx.service - nginx\n     Loaded: loaded (\u002Fusr\u002Flib\u002Fsystemd\u002Fsystem\u002Fnginx.service; disabled; preset: disabled)\n     Active: active (running) since Wed 2026-09-02 10:59:58 CST; 7s ago\n Invocation: c7d50f2edde24e01b45bd3a7e33d8f8c\n    Process: 14300 ExecStart=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx (code=exited, status=0\u002FSUCCESS)\n   Main PID: 14301 (nginx)\n      Tasks: 2 (limit: 10320)\n     Memory: 1.9M (peak: 2.3M)\n        CPU: 8ms\n     CGroup: \u002Fsystem.slice\u002Fnginx.service\n             ├─14301 \"nginx: master process \u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx\"\n             └─14302 \"nginx: worker process\"\n\nSep 02 10:59:58 localhost systemd[1]: Starting nginx.service - nginx...\nSep 02 10:59:58 localhost systemd[1]: Started nginx.service - nginx.\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>重载服务配置并启动\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# nginx -t          # 检查配置语法\n[root@localhost ~]# nginx -s reload   # 平滑重启\n[root@localhost ~]# nginx -s stop     # 快速停止\n[root@localhost ~]# nginx -s quit     # 优雅停止\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>8、备份默认配置文件后，对 nginx.conf 进行高并发调优，适配生产大流量场景，开启压缩、连接优化、状态监控等功能。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# cd \u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002F\n[root@localhost conf]# ll\ntotal 68\n-rw-r--r-- 1 root root 1077 Sep  2 10:33 fastcgi.conf\n-rw-r--r-- 1 root root 1077 Sep  2 10:34 fastcgi.conf.default\n-rw-r--r-- 1 root root 1007 Sep  2 10:33 fastcgi_params\n-rw-r--r-- 1 root root 1007 Sep  2 10:34 fastcgi_params.default\n-rw-r--r-- 1 root root 2837 Sep  2 10:34 koi-utf\n-rw-r--r-- 1 root root 2223 Sep  2 10:34 koi-win\n-rw-r--r-- 1 root root 5349 Sep  2 10:33 mime.types\n-rw-r--r-- 1 root root 5349 Sep  2 10:34 mime.types.default\n-rw-r--r-- 1 root root 2630 Sep  2 10:33 nginx.conf\n-rw-r--r-- 1 root root 2630 Sep  2 10:34 nginx.conf.default\n-rw-r--r-- 1 root root  636 Sep  2 10:33 scgi_params\n-rw-r--r-- 1 root root  636 Sep  2 10:34 scgi_params.default\n-rw-r--r-- 1 root root  664 Sep  2 10:33 uwsgi_params\n-rw-r--r-- 1 root root  664 Sep  2 10:34 uwsgi_params.default\n-rw-r--r-- 1 root root 3611 Sep  2 10:34 win-utf\n[root@localhost conf]# \n[root@localhost conf]# cp -a nginx.conf nginx.conf.bak\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>替换完整优化配置\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# vim \u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf\n# ------------------------------------\n# 全局配置\n# ------------------------------------\nuser nginx nginx;\nworker_processes auto;\nworker_cpu_affinity auto;\nworker_rlimit_nofile 65535;\nerror_log \u002Fvar\u002Flog\u002Fnginx\u002Ferror.log warn;\npid \u002Fvar\u002Frun\u002Fnginx.pid;\n\n# -------------------------------\n# Events 块\n# ------------------------------\nevents {\n    use epoll;\n    worker_connections 65535;\n    multi_accept on;\n}\n\n# --------------------------\n# HTTP块通用调优\n# --------------------------\n\nhttp {\n    include       mime.types;\n    default_type  application\u002Foctet-stream;\n\n    log_format  main  '$remote_addr - $remote_user [$time_local] \"$request\" '\n                      '$status $body_bytes_sent \"$http_referer\" '\n                      '\"$http_user_agent\" \"$http_x_forwarded_for\"';\n\n    access_log  \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log  main;\n\n    # 调优参数\n    sendfile on;\n    tcp_nopush on;\n    tcp_nodelay on;\n    keepalive_timeout 65;\n    keepalive_requests 1000;\n    client_max_body_size 100M;\n    client_body_buffer_size 128k;\n    client_header_buffer_size 4k;\n    large_client_header_buffers 4 32k;\n    client_header_timeout 10;\n    client_body_timeout 10;\n    send_timeout 10;\n    gzip on;\n    gzip_min_length 1k;\n    gzip_buffers 4 16k;\n    gzip_http_version 1.1;\n    gzip_comp_level 6;\n    gzip_types text\u002Fplain text\u002Fcss application\u002Fjson application\u002Fjavascript text\u002Fxml application\u002Fxml application\u002Fxml+rss text\u002Fjavascript;\n    gzip_vary on;\n\n    include vhost\u002F*.conf;\n\n    server {\n        listen       80;\n        server_name  localhost;\n\n        location \u002F {\n            root   html;\n            index  index.html index.htm;\n\t    allow 0.0.0.0;\n        }\n\n        error_page   500 502 503 504  \u002F50x.html;\n        location = \u002F50x.html {\n            root   html;\n        }\n\n\t# 性能监控\n\tlocation \u002Fnginx-status{\n\t    stub_status on;\n\t    allow 127.0.0.1;\n\t    deny all;\n\t}\n    }\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>9、高并发场景依赖系统内核参数优化，调整TCP连接、文件句柄等核心参数，突破系统默认限制。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# vim \u002Fetc\u002Fsysctl.conf\n\nnet.ipv4.tcp_syncookies = 1\nnet.ipv4.tcp_tw_reuse = 1\nnet.ipv4.tcp_fin_timeout = 30\nnet.ipv4.tcp_keepalive_time = 1200\nnet.ipv4.ip_local_port_range = 1024 65535\nnet.ipv4.tcp_max_syn_backlog = 8192\nnet.ipv4.tcp_max_tw_buckets = 5000\nfs.file-max = 6553500\n\n[root@localhost ~]# sysctl -p\n[root@localhost ~]# cat \u002Fproc\u002Fsys\u002Ffs\u002Ffile-max \n6553500\n[root@localhost ~]# cat \u002Fproc\u002Fsys\u002Fnet\u002Fipv4\u002Ftcp_tw_reuse \n1\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>10、调高Nginx用户文件句柄最大限制，解决高并发下文件打开数耗尽问题，修改后需重新登录会话生效。\u003C\u002Fp>\n\u003Cpre>\u003Ccode>[root@localhost ~]# vim \u002Fetc\u002Fsecurity\u002Flimits.conf\nnginx soft nofile 65535\nnginx hard nofile 65535\n\n[root@localhost ~]# ulimit -n\n65535\n\u003C\u002Fcode>\u003C\u002Fpre>","Nginx 是一款轻量级、高性能、高并发的开源Web服务器、反向代理与负载均衡软件，凭借低资源占用、高稳定性的核心优势，成为当下互联网行业主流的服务部署组件，广泛应用于各类网站及业务系统的Web服务、反向代理、负载均衡场景。其基于宽松的类BSD开源协议发布，可免费商用。本文将完整展示 Nginx 1.30.4 源码编译安装、环境配置、systemd服务管理、内核及配置高性能调优的全套流程，适配CentOS\u002FRHEL 10系列系统，可直接落地应用于企业生产环境。 1、源码编译需要gcc编译工具、正则、加密、压缩等依赖库，先执行依赖安装命令，确保编译环境完整。 [root@localhost ~]# dnf install -y epel-release [root@localhost ~]# dnf install -y gcc gcc-c++ make zlib zlib-devel pcre2 pcre2-devel openssl openssl-devel libtool Last metadata expiration check: 0:25:59 ago on Wed 02 Sep 2026 10:03:21 AM CST. Package gcc-14.4.1-3.el10.x86_64 is already installed. Package gcc-c++-14.4.1-3.el10.x86_64 is already installed. Package make-1:4.4.1-9.el10.x86_64 is already installed. Package zlib-ng-compat-2.2.3-3.el10.x86_64 is already installed. Package zlib-ng-compat-devel-2.2.3-3.el10.x86_64 is already installed. Package pcre2-10.44-1.el10.3.x86_64 is already installed. Package pcre2-devel-10.44-1.el10.3.x86_64 is already installed. Package openssl-1:3.5.8-1.el10.x86_64 is already installed. Package openssl-devel-1:3.5.8-1.el10.x86_64 is already installed. Package libtool-2.4.7-14.el10.x86_64 is already installed. Dependencies resolved. Nothing to do. Complete! 2、从Nginx官方镜像下载稳定版1.30.4源码包，解压后进入源码目录，为编译做准备。 [root@localhost ~]# wget https:\u002F\u002Fnginx.org\u002Fdownload\u002Fnginx-1.30.4.tar.gz [root@localhost ~]# tar -xzvf nginx-1.30.4.tar.gz [root@localhost nginx-1.30.4]# ls -lh total 916K drwxr-xr-x 6 502 wheel 4.0K Sep 2 10:28 auto -rw-r--r-- 1 502 wheel 338K Jul 16 01:24 CHANGES -rw-r--r-- 1 502 wheel 517K Jul 16 01:24 CHANGES.ru -rw-r--r-- 1 502 wheel 5.1K Jul 16 01:20 CODE_OF_CONDUCT.md drwxr-xr-x 2 502 wheel 168 Sep 2 10:28 conf -rwxr-xr-x 1 502 wheel 2.6K Jul 16 01:20 configure drwxr-xr-x 4 502 wheel 72 Sep 2 10:28 contrib -rw-r--r-- 1 502 wheel 4.9K Jul 16 01:20 CONTRIBUTING.md drwxr-xr-x 2 502 wheel 40 Sep 2 10:28 html -rw-r--r-- 1 502 wheel 1.3K Jul 16 01:20 LICENSE drwxr-xr-x 2 502 wheel 21 Sep 2 10:28 man -rw-r--r-- 1 502 wheel 15K Jul 16 01:20 README.md -rw-r--r-- 1 502 wheel 4.8K Jul 16 01:20 SECURITY.md drwxr-xr-x 9 502 wheel 91 Jul 16 01:20 src -rw-r--r-- 1 502 wheel 1.7K Jul 16 01:20 SUPPORT.md 3、为保证服务安全，创建不可登录系统用户运行Nginx，同时创建临时文件目录、日志存储目录，规范文件管理。 [root@localhost ~]# useradd -s \u002Fsbin\u002Fnologin nginx [root@localhost ~]# mkdir -p \u002Fvar\u002Ftmp\u002Fnginx [root@localhost ~]# mkdir -p \u002Fvar\u002Flog\u002Fnginx 4、自定义Nginx安装路径、日志路径、进程文件路径，同时开启SSL、状态监控、反向代理、流媒体等核心常用模块，适配绝大多数生产场景。 [root@localhost nginx-1.30.4]# mkdir -p \u002Fusr\u002Flocal\u002Fnginx [root@localhost nginx-1.30.4]# .\u002Fconfigure \\ --user=nginx \\ --group=nginx \\ --prefix=\u002Fusr\u002Flocal\u002Fnginx \\ --sbin-path=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx \\ --conf-path=\u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf \\ --error-log-path=\u002Fvar\u002Flog\u002Fnginx\u002Ferror.log \\ --http-log-path=\u002Fvar\u002Flog\u002Fnginx\u002Faccess.log \\ --pid-path=\u002Fvar\u002Frun\u002Fnginx.pid \\ --lock-path=\u002Fvar\u002Frun\u002Fnginx.lock \\ --http-client-body-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Fclient_body \\ --http-proxy-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Fproxy \\ --http-fastcgi-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Ffastcgi \\ --http-uwsgi-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Fuwsgi \\ --http-scgi-temp-path=\u002Fvar\u002Ftmp\u002Fnginx\u002Fscgi \\ --with-http_ssl_module \\ --with-http_stub_status_module \\ --with-http_realip_module \\ --with-http_sub_module \\ --with-http_addition_module \\ --with-http_random_index_module \\ --with-http_secure_link_module \\ --with-http_gunzip_module \\ --with-http_gzip_static_module \\ --with-stream \\ --with-stream_ssl_module [root@localhost nginx-1.30.4]# make [root@localhost nginx-1.30.4]# make install 默认Nginx会暴露版本号，存在一定安全风险，可通过修改源码文件隐藏版本信息（本文仅展示配置，按需修改）。 [root@localhost ~]# vim nginx-1.30.4\u002Fsrc\u002Fcore\u002Fnginx.h #define nginx_version 1030004 #define NGINX_VERSION \"1.30.4\" #define NGINX_VER \"nginx\u002F\" NGINX_VERSION #ifdef NGX_BUILD #define NGINX_VER_BUILD NGINX_VER \" (\" NGX_BUILD \")\" #else #define NGINX_VER_BUILD NGINX_VER #endif #define NGINX_VAR \"NGINX\" #define NGX_OLDPID_EXT \".oldbin\" 5、通过版本命令验证安装是否成功，确认编译参数、依赖版本无误。输出包含Nginx版本、GCC编译版本、OpenSSL版本及已开启的模块，即代表编译安装成功。 [root@localhost nginx-1.30.4]# cd [root@localhost ~]# \u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx -V nginx version: nginx\u002F1.30.4 built by gcc 14.4.1 20260724 (Red Hat 14.4.1-3) (GCC) built with OpenSSL 3.5.8 25 Aug 2026 TLS SNI support enabled 6、为方便全局调用nginx命令，将程序路径加入系统环境变量。 [root@localhost ~]# echo 'export PATH=$PATH:\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin' >> \u002Fetc\u002Fprofile [root@localhost ~]# source \u002Fetc\u002Fprofile [root@localhost ~]# nginx -v nginx version: nginx\u002F1.30.4 7、创建systemd服务文件，实现Nginx开机自启、启停、重载管理，适配系统服务管理规范。 [root@localhost ~]# vim \u002Fusr\u002Flib\u002Fsystemd\u002Fsystem\u002Fnginx.service [Unit] Description=nginx After=network.target [Service] Type=forking ExecStart=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx ExecReload=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx -s reload ExecStop=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx -s stop [Install] WantedBy=multi-user.target [root@localhost ~]# systemctl daemon-reload [root@localhost ~]# systemctl start nginx [root@localhost ~]# systemctl status nginx ● nginx.service - nginx Loaded: loaded (\u002Fusr\u002Flib\u002Fsystemd\u002Fsystem\u002Fnginx.service; disabled; preset: disabled) Active: active (running) since Wed 2026-09-02 10:59:58 CST; 7s ago Invocation: c7d50f2edde24e01b45bd3a7e33d8f8c Process: 14300 ExecStart=\u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx (code=exited, status=0\u002FSUCCESS) Main PID: 14301 (nginx) Tasks: 2 (limit: 10320) Memory: 1.9M (peak: 2.3M) CPU: 8ms CGroup: \u002Fsystem.slice\u002Fnginx.service ├─14301 \"nginx: master process \u002Fusr\u002Flocal\u002Fnginx\u002Fsbin\u002Fnginx\" └─14302 \"nginx: worker process\" Sep 02 10:59:58 localhost systemd[1]: Starting nginx.service - nginx... Sep 02 10:59:58 localhost systemd[1]: Started nginx.service - nginx. 重载服务配置并启动 [root@localhost ~]# nginx -t # 检查配置语法 [root@localhost ~]# nginx -s reload # 平滑重启 [root@localhost ~]# nginx -s stop # 快速停止 [root@localhost ~]# nginx -s quit # 优雅停止 8、备份默认配置文件后，对 nginx.conf 进行高并发调优，适配生产大流量场景，开启压缩、连接优化、状态监控等功能。 [root@localhost ~]# cd \u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002F [root@localhost conf]# ll total 68 -rw-r--r-- 1 root root 1077 Sep 2 10:33 fastcgi.conf -rw-r--r-- 1 root root 1077 Sep 2 10:34 fastcgi.conf.default -rw-r--r-- 1 root root 1007 Sep 2 10:33 fastcgi_params -rw-r--r-- 1 root root 1007 Sep 2 10:34 fastcgi_params.default -rw-r--r-- 1 root root 2837 Sep 2 10:34 koi-utf -rw-r--r-- 1 root root 2223 Sep 2 10:34 koi-win -rw-r--r-- 1 root root 5349 Sep 2 10:33 mime.types -rw-r--r-- 1 root root 5349 Sep 2 10:34 mime.types.default -rw-r--r-- 1 root root 2630 Sep 2 10:33 nginx.conf -rw-r--r-- 1 root root 2630 Sep 2 10:34 nginx.conf.default -rw-r--r-- 1 root root 636 Sep 2 10:33 scgi_params -rw-r--r-- 1 root root 636 Sep 2 10:34 scgi_params.default -rw-r--r-- 1 root root 664 Sep 2 10:33 uwsgi_params -rw-r--r-- 1 root root 664 Sep 2 10:34 uwsgi_params.default -rw-r--r-- 1 root root 3611 Sep 2 10:34 win-utf [root@localhost conf]# [root@localhost conf]# cp -a nginx.conf nginx.conf.bak 替换完整优化配置 [root@localhost ~]# vim \u002Fusr\u002Flocal\u002Fnginx\u002Fconf\u002Fnginx.conf # ------------------------------------ # 全局配置 # ------------------------------------ user nginx nginx; worker_processes auto; worker_cpu_affinity auto; worker_rlimit_nofile 65535; error_log \u002Fvar\u002Flog\u002Fnginx\u002Ferror.log warn; pid \u002Fvar\u002Frun\u002Fnginx.pid; # ------------------------------- # Events 块 # ------------------------------ events { use epoll; worker_connections 65535; multi_accept on; } # -------------------------- # HTTP块通用调优 # -------------------------- http { include mime.types; default_type application\u002Foctet-stream; log_format main '$remote_addr - $remote_user [$time_local] \"$request\" ' '$status $body_bytes_sent \"$http_referer\" ' '\"$http_user_agent\" \"$http_x_forwarded_for\"'; access_log \u002Fvar\u002Flog\u002Fnginx\u002Faccess.log main; # 调优参数 sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; keepalive_requests 1000; client_max_body_size 100M; client_body_buffer_size 128k; client_header_buffer_size 4k; large_client_header_buffers 4 32k; client_header_timeout 10; client_body_timeout 10; send_timeout 10; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 6; gzip_types text\u002Fplain text\u002Fcss application\u002Fjson application\u002Fjavascript text\u002Fxml application\u002Fxml application\u002Fxml+rss text\u002Fjavascript; gzip_vary on; include vhost\u002F*.conf; server { listen 80; server_name localhost; location \u002F { root html; index index.html index.htm; allow 0.0.0.0; } error_page 500 502 503 504 \u002F50x.html; location = \u002F50x.html { root html; } # 性能监控 location \u002Fnginx-status{ stub_status on; allow 127.0.0.1; deny all; } } } 9、高并发场景依赖系统内核参数优化，调整TCP连接、文件句柄等核心参数，突破系统默认限制。 [root@localhost ~]# vim \u002Fetc\u002Fsysctl.conf net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.ip_local_port_range = 1024 65535 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_max_tw_buckets = 5000 fs.file-max = 6553500 [root@localhost ~]# sysctl -p [root@localhost ~]# cat \u002Fproc\u002Fsys\u002Ffs\u002Ffile-max 6553500 [root@localhost ~]# cat \u002Fproc\u002Fsys\u002Fnet\u002Fipv4\u002Ftcp_tw_reuse 1 10、调高Nginx用户文件句柄最大限制，解决高并发下文件打开数耗尽问题，修改后需重新登录会话生效。 [root@localhost ~]# vim \u002Fetc\u002Fsecurity\u002Flimits.conf nginx soft nofile 65535 nginx hard nofile 65535 [root@localhost ~]# ulimit -n 65535",8036,{"id":6,"kind":7,"title":11,"summary":13,"image":14,"href":15,"meta":36,"badge":10,"author":12,"stats":-1,"accent":37,"coverRatio":38,"tags":39},"2026 · 云原生与运维","#2563eb","16 \u002F 10",[18],{"targetType":8,"targetId":9,"likedByMe":41,"likeCount":42,"commentCount":42,"contentLikeCount":42,"contentCommentCount":42,"sourceLikeCount":42,"sourceCommentCount":42},false,0,[44,51,57,64,73,79,86,94],{"id":45,"kind":7,"title":46,"summary":47,"image":48,"href":49,"meta":36,"badge":10,"author":12,"stats":-1,"accent":37,"coverRatio":38,"tags":50},"NEWS_ARTICLE:885","【Azure Redis】中国区创建和连接 Azure Managed Redis 的两个注意事项","Azure Managed Redis 介绍 Azure Managed Redis 是微软新一代全托管 Redis 服务，基于 Redis Enterprise 构建，为现代云应用提供低延迟、高吞吐的数据访问能力。相比传统 Azure Cache for Redis，它采用更高效的多分片架构，并提","https:\u002F\u002Fimg2024.cnblogs.com\u002Fblog\u002F2127802\u002F202608\u002F2127802-20260831195905463-1387904592.png","\u002Fnews\u002F885",[18],{"id":52,"kind":7,"title":53,"summary":54,"image":14,"href":55,"meta":36,"badge":10,"author":12,"stats":-1,"accent":37,"coverRatio":38,"tags":56},"NEWS_ARTICLE:891","K8S接入NFS存储","本文详细演示了在Kubernetes集群中接入NFS作为默认持久化存储的完整流程。针对容器数据易失问题，文章介绍了如何部署NFS Provisioner，并配置StorageClass将其设为集群默认（default）。通过此方案，实现了PVC的动态自动供给，开发者无需手动创建PV即可为Pod分配存","\u002Fnews\u002F891",[18],{"id":58,"kind":7,"title":59,"summary":60,"image":61,"href":62,"meta":36,"badge":10,"author":12,"stats":-1,"accent":37,"coverRatio":38,"tags":63},"NEWS_ARTICLE:911","k8s安装metrics-server，以及相关报错排查","背景：有监控node节点pod的CPU等资源，实现自动扩缩容的需要下，需要安装metrics-server k8s版本：1.30.14（kubadm安装） 对应metrics-server版本：0.8x（本文使用0.8.1） 1、下载部署清单 wget https:\u002F\u002Fgithub.com\u002Fkube","https:\u002F\u002Fimg2024.cnblogs.com\u002Fblog\u002F1384371\u002F202608\u002F1384371-20260830185204348-546969162.png","\u002Fnews\u002F911",[18],{"id":65,"kind":7,"title":66,"summary":67,"image":68,"href":69,"meta":70,"badge":10,"author":12,"stats":-1,"accent":37,"coverRatio":38,"tags":71},"NEWS_ARTICLE:827","MHS 三部曲（下）：谁允许 AI 行动？——权力、合规与中国厂商的答卷","我们总在等待一个像 ChatGPT 那样的机器人时刻。但具身智能真正的拐点，也许先发生在更不起眼的地方：一台陌生设备，第一次能把自己的能力、状态和边界完整告诉 AI；一个 Agent，第一次能把试出来的经验固化成可验证、可复用的机器技能。","https:\u002F\u002Fimg2024.cnblogs.com\u002Fblog\u002F510\u002F202608\u002F510-20260830153745229-1536981088.jpg","\u002Fnews\u002F827","2026 · 人工智能",[72],"人工智能",{"id":74,"kind":7,"title":75,"summary":76,"image":14,"href":77,"meta":17,"badge":10,"author":12,"stats":-1,"accent":37,"coverRatio":38,"tags":78},"NEWS_ARTICLE:829","我不会美工，用 WorkBuddy 1 分钟做出 4 张海报","先说结果：下面这 4 张海报，从我发出指令到拿到图片，大约 1 分钟。 我不会美工，也没有打开 Photoshop。用的工具，是我之前用 WorkBuddy 做的一个海报生成器。这个生成器本身也没花几分钟，具体开发过程我在上一篇文章里写过。 这次我把海报生成器的网址、产品截图和要求一起发给 Work","\u002Fnews\u002F829",[7,8],{"id":80,"kind":7,"title":81,"summary":82,"image":83,"href":84,"meta":17,"badge":10,"author":12,"stats":-1,"accent":37,"coverRatio":38,"tags":85},"NEWS_ARTICLE:828","一个人抵一个团队的时代，企业级 AI Agent 还需要做什么？","对于企业而言，真正需要的，不是一个“会聊天”的 Agent，而是一套能被多用户、多场景复用，且权限清晰、过程可审计、成本可控制的 Agent 能力体系。","https:\u002F\u002Fimg2024.cnblogs.com\u002Fblog\u002F2232255\u002F202609\u002F2232255-20260902173524728-659996478.png","\u002Fnews\u002F828",[7,8],{"id":87,"kind":7,"title":88,"summary":89,"image":14,"href":90,"meta":91,"badge":10,"author":12,"stats":-1,"accent":37,"coverRatio":38,"tags":92},"NEWS_ARTICLE:832","用 runtime-async 写一个支持 async\u002Fawait 的轻量脚本引擎","起因：一个好奇 事情的开头很简单。 给 .NET 做过动态脚本的人大概都碰到过同一堵墙：表达式树也好、Reflection.Emit 也好，都很难支持 async\u002Fawait。原因不在语法，而在 await 的实现方式——C# 编译器要为每个 async 方法生成一个状态机结构体，把方法体切成若干片","\u002Fnews\u002F832","2026 · 软件开发",[93],"软件开发",{"id":95,"kind":7,"title":96,"summary":97,"image":98,"href":99,"meta":17,"badge":10,"author":12,"stats":-1,"accent":37,"coverRatio":38,"tags":100},"NEWS_ARTICLE:831","Agent Sandbox 规模化：JuiceFS 探索与实践","过去一段时间，我们在和云厂商以及 Agent 团队推进 Sandbox 落地时，除了要解决数据如何进入 Sandbox，还需要考虑任务所需的数据和执行过程中产生的数据，如何跨任务、跨阶段持续使用。Sandbox 可以随任务快速创建和销毁，但数据往往需要继续保留、共享和流转。 当 Sandbox 并发","https:\u002F\u002Fimg2024.cnblogs.com\u002Fblog\u002F2544292\u002F202609\u002F2544292-20260902171045357-1907499098.png","\u002Fnews\u002F831",[7,8]]