{"id":600,"date":"2022-08-27T13:33:07","date_gmt":"2022-08-27T05:33:07","guid":{"rendered":"https:\/\/frogvps.com\/?p=600"},"modified":"2022-09-24T23:21:55","modified_gmt":"2022-09-24T15:21:55","slug":"nginx%e5%ae%89%e8%a3%85%e7%ac%ac%e4%b8%89%e6%96%b9%e6%a8%a1%e5%9d%97echo","status":"publish","type":"post","link":"https:\/\/frogvps.com\/?p=600","title":{"rendered":"nginx\u5b89\u88c5\u7b2c\u4e09\u65b9\u6a21\u5757echo"},"content":{"rendered":"\n<p>\u5b89\u88c5\u4f9d\u8d56<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>centos\nyum -y install gcc pcre-devel openssl-devel zlib-devel libxslt-devel libxml2-devel gd-devel\nubuntu\napt -y install libpcre3-dev libssl-dev zlib1g-dev libxml2-dev libxslt1-dev libgd-dev<\/code><\/pre>\n\n\n\n<p>\u4e0b\u8f7dnginx\u6700\u65b0\u7a33\u5b9a\u7248\u7684\u6e90\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/usr\/local\/src\nwget http:\/\/nginx.org\/download\/nginx-1.22.0.tar.gz<\/code><\/pre>\n\n\n\n<p>\u89e3\u5305<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar xvf nginx-1.22.0.tar.gz<\/code><\/pre>\n\n\n\n<p>\u4e0b\u8f7d\u7b2c\u4e09\u65b9echo\u6a21\u5757<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/usr\/local\/src\ngit clone https:\/\/github.com\/openresty\/echo-nginx-module.git<\/code><\/pre>\n\n\n\n<p>\u67e5\u770b\u4e4b\u524dnginx\u7684\u7f16\u8bd1\u9009\u9879<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx -V<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>--with-cc-opt='-g -O2 -fdebug-prefix-map=\/build\/nginx-7KvRN5\/nginx-1.22.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=\/usr\/share\/nginx --conf-path=\/etc\/nginx\/nginx.conf --http-log-path=\/var\/log\/nginx\/access.log --error-log-path=\/var\/log\/nginx\/error.log --lock-path=\/var\/lock\/nginx.lock --pid-path=\/run\/nginx.pid --modules-path=\/usr\/lib\/nginx\/modules --http-client-body-temp-path=\/var\/lib\/nginx\/body --http-fastcgi-temp-path=\/var\/lib\/nginx\/fastcgi --http-proxy-temp-path=\/var\/lib\/nginx\/proxy --http-scgi-temp-path=\/var\/lib\/nginx\/scgi --http-uwsgi-temp-path=\/var\/lib\/nginx\/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module<\/code><\/pre>\n\n\n\n<p>\u8fdb\u5165\u76ee\u5f55\u7f16\u8bd1\u5b89\u88c5<\/p>\n\n\n\n<p>\u5728\u539f\u6709\u7684\u9009\u9879\u540e\u9762\u6dfb\u52a0 &#8211;add-module=\u7b2c\u4e09\u65b9\u6a21\u5757\u8def\u5f84<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd nginx-1.22.0\/\n.\/configure --with-cc-opt='-g -O2 -fdebug-prefix-map=\/build\/nginx-7KvRN5\/nginx-1.22.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=\/usr\/share\/nginx --conf-path=\/etc\/nginx\/nginx.conf --http-log-path=\/var\/log\/nginx\/access.log --error-log-path=\/var\/log\/nginx\/error.log --lock-path=\/var\/lock\/nginx.lock --pid-path=\/run\/nginx.pid --modules-path=\/usr\/lib\/nginx\/modules --http-client-body-temp-path=\/var\/lib\/nginx\/body --http-fastcgi-temp-path=\/var\/lib\/nginx\/fastcgi --http-proxy-temp-path=\/var\/lib\/nginx\/proxy --http-scgi-temp-path=\/var\/lib\/nginx\/scgi --http-uwsgi-temp-path=\/var\/lib\/nginx\/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module --add-module=\/usr\/local\/src\/echo-nginx-module<\/code><\/pre>\n\n\n\n<p>\u7f16\u8bd1\u5b8c\u6ca1\u6709\u62a5\u9519\u540e\u6267\u884cmake \u548c make install<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make\nmake install<\/code><\/pre>\n\n\n\n<p>\u7531\u4e8e\u4e4b\u524d\u6211\u7528\u5305\u81ea\u52a8\u5b89\u88c5\u7684nginx\u53ef\u6267\u884c\u7a0b\u5e8f\u5728\/usr\/sbin\u4e0b\u9762<\/p>\n\n\n\n<p>\u5148\u5907\u4efd\u539f\u6765\u7684nginx<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mv \/usr\/sbin\/nginx \/usr\/sbin\/nginx.bak<\/code><\/pre>\n\n\n\n<p>\u7ed9\u65b0\u7684nginx\u521b\u5efa\u8f6f\u8fde\u63a5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ln -s \/usr\/share\/nginx\/sbin\/nginx  \/usr\/sbin\/nginx <\/code><\/pre>\n\n\n\n<p>\u68c0\u67e5\u8bed\u6cd5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/sbin\/nginx -t<\/code><\/pre>\n\n\n\n<p>\u53d1\u9001USER2\u4fe1\u53f7\u5e73\u6ed1\u5347\u7ea7<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kill -USR2 $(cat \/run\/nginx.pid)<\/code><\/pre>\n\n\n\n<p>\u6b64\u65f6Nginx\u5f00\u542f\u4e00\u4e2a\u65b0\u7684master\u8fdb\u7a0b\uff0c\u8fd9\u4e2amaster\u8fdb\u7a0b\u4f1a\u751f\u6210\u65b0\u7684worker\u8fdb\u7a0b\uff0c\u8fd9\u5c31\u662f\u5347\u7ea7\u540e\u7684Nginx\u8fdb\u7a0b\uff0c\u6b64\u65f6\u8001\u7684\u8fdb\u7a0b\u4e0d\u4f1a\u81ea\u52a8\u9000\u51fa\uff0c\u4f46\u662f\u5f53\u63a5\u6536\u5230\u65b0\u7684\u8bf7\u6c42\u4e0d\u4f5c\u5904\u7406\u800c\u662f\u4ea4\u7ed9\u65b0\u7684\u8fdb\u7a0b\u5904\u7406\u3002<\/p>\n\n\n\n<p>\u6b64\u65f6\u4e24\u4e2amaster\u7684\u8fdb\u7a0b\u90fd\u5728\u8fd0\u884c\uff0c\u53ea\u662f\u65e7\u7684master\u4e0d\u5728\u76d1\u542c\uff0c\u7531\u65b0\u7684master\u76d1\u542c80\u3002<\/p>\n\n\n\n<p>\u5411\u539fNginx\u4e3b\u8fdb\u7a0b\u53d1\u9001WINCH\u4fe1\u53f7\uff0c\u5b83\u4f1a\u9010\u6b65\u5173\u95ed\u65d7\u4e0b\u7684\u5de5\u4f5c\u8fdb\u7a0b\uff08\u4e3b\u8fdb\u7a0b\u4e0d\u9000\u51fa\uff09\uff0c\u8fd9\u65f6\u6240\u6709\u8bf7\u6c42\u90fd\u4f1a\u7531\u65b0\u7248Nginx\u5904\u7406<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kill -WINCH $(cat \/run\/nginx.pid.oldbin)<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u65e7\u7248worker\u8fdb\u7a0b\u6709\u7528\u6237\u7684\u8bf7\u6c42,\u4f1a\u4e00\u76f4\u7b49\u5f85\u5904\u7406\u5b8c\u540e\u624d\u4f1a\u5173\u95ed\u3002<\/p>\n\n\n\n<p>\u7ecf\u8fc7\u4e00\u6bb5\u65f6\u95f4\u6d4b\u8bd5\uff0c\u65b0\u7248\u672c\u670d\u52a1\u6ca1\u95ee\u9898\uff0c\u6700\u540e\u9000\u51fa\u8001\u7684master\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kill -QUIT $(cat \/run\/nginx.pid.oldbin)<\/code><\/pre>\n\n\n\n<p>\u8fd9\u65f6\u5019\u518d\u67e5\u770bnginx\u7684\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx -v <\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"482\" height=\"59\" src=\"https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220827a1.jpg\" alt=\"\" class=\"wp-image-601\" srcset=\"https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220827a1.jpg 482w, https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220827a1-300x37.jpg 300w\" sizes=\"auto, (max-width: 482px) 100vw, 482px\" \/><figcaption>\u7248\u672c\u5df2\u7ecf\u5347\u7ea7\u6210\u529f\u4e86<\/figcaption><\/figure>\n\n\n\n<p>\u8fd9\u65f6\u5019echo\u6a21\u5757\u5c31\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\u4e86<\/p>\n\n\n\n<p>\u6d4b\u8bd5\u4e0b\u5728\u914d\u7f6e\u6587\u4ef6\u91cc\u6dfb\u52a0\u663e\u793aIP\u7684\u529f\u80fd<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>location ~ \/ip {\n  root   \/var\/www\/html;\n  default_type text\/html;\n  echo \"your IP:\";\n  echo $remote_addr;\n     }<\/code><\/pre>\n\n\n\n<p>\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx -s reload\n#\u4e5f\u53ef\u4ee5\u53d1\u9001HUP\u4fe1\u53f7\nkill -HUP $(cat \/run\/nginx.pid)<\/code><\/pre>\n\n\n\n<p>\u7528\u6d4f\u89c8\u5668\u67e5\u770b\u663e\u793a\u7ed3\u679c<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"375\" src=\"https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220827a2.jpg\" alt=\"\" class=\"wp-image-602\" srcset=\"https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220827a2.jpg 750w, https:\/\/frogvps.com\/wp-content\/uploads\/2022\/08\/20220827a2-300x150.jpg 300w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5\u4f9d\u8d56 \u4e0b\u8f7dnginx\u6700\u65b0\u7a33\u5b9a\u7248\u7684\u6e90\u7801 \u89e3\u5305 \u4e0b\u8f7d\u7b2c\u4e09\u65b9echo\u6a21\u5757 \u67e5\u770b\u4e4b\u524dnginx\u7684\u7f16\u8bd1\u9009\u9879 \u8fdb\u5165\u76ee\u5f55\u7f16\u8bd1\u5b89\u88c5 \u5728\u539f\u6709\u7684\u9009\u9879\u540e\u9762\u6dfb\u52a0 &#8211;add-module=\u7b2c\u4e09\u65b9\u6a21\u5757\u8def\u5f84 \u7f16\u8bd1\u5b8c\u6ca1\u6709\u62a5\u9519\u540e\u6267\u884cmake \u548c make i&#8230;<\/p>\n","protected":false},"author":1,"featured_media":53,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14],"topic":[],"class_list":["post-600","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-nginx"],"_links":{"self":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts\/600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=600"}],"version-history":[{"count":2,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts\/600\/revisions"}],"predecessor-version":[{"id":604,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/posts\/600\/revisions\/604"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=\/wp\/v2\/media\/53"}],"wp:attachment":[{"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=600"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/frogvps.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftopic&post=600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}