{"id":118,"date":"2017-08-07T01:44:39","date_gmt":"2017-08-07T01:44:39","guid":{"rendered":"https:\/\/oimi.me\/?p=118"},"modified":"2017-08-07T01:44:39","modified_gmt":"2017-08-07T01:44:39","slug":"centos-7-x-rhel-7-x-%e4%b8%8b%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85%e6%9c%80%e6%96%b0%e7%89%88-nginx","status":"publish","type":"post","link":"https:\/\/myya.net\/index.php\/2017\/08\/07\/centos-7-x-rhel-7-x-%e4%b8%8b%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85%e6%9c%80%e6%96%b0%e7%89%88-nginx\/","title":{"rendered":"CentOS 7.x \/ RHEL 7.x \u4e0b\u7f16\u8bd1\u5b89\u88c5\u6700\u65b0\u7248 Nginx"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-119\" src=\"https:\/\/cdn.oimi.me\/wp-content\/uploads\/2017\/08\/2017080709430237.png\" alt=\"\" width=\"352\" height=\"72\" srcset=\"https:\/\/myya.net\/wp-content\/uploads\/2017\/08\/2017080709430237.png 352w, https:\/\/myya.net\/wp-content\/uploads\/2017\/08\/2017080709430237-300x61.png 300w\" sizes=\"auto, (max-width: 352px) 100vw, 352px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>\u6240\u4ee5\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u5728 CentOS 7.x \/ RHEL 7.x \u4e0b\u7f16\u8bd1\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684 Nginx<\/p>\n<p><em>\u672c\u6559\u7a0b\u540c\u6837\u9002\u5408 Debian \/ Ubuntu \u4f46\u662f Debian \u548c Ubuntu \u4e0b\u9664\u975e\u8981\u88c5\u7b2c\u4e09\u65b9\u7684\u6a21\u5757\uff0c\u5426\u5219\u4e0d\u662f\u5f88\u63a8\u8350\u7f16\u8bd1\u5b89\u88c5<\/em><!--more--><\/p>\n<p>\u6211\u4eec\u5148\u505a\u4e00\u4e2a\u7b80\u5355\u7684\u5bf9\u6bd4<\/p>\n<p>\u901a\u8fc7\u5b98\u65b9\u6e90\u5b89\u88c5\u7684 Nginx<\/p>\n<pre class=\"hljs python\"><code class=\"language-bash\">root@centos<span class=\"hljs-number\">-7<\/span>-dev:~ <span class=\"hljs-comment\"># nginx -V<\/span>\nnginx version: nginx\/<span class=\"hljs-number\">1.12<\/span><span class=\"hljs-number\">.1<\/span>\nbuilt by gcc <span class=\"hljs-number\">4.8<\/span><span class=\"hljs-number\">.5<\/span> <span class=\"hljs-number\">20150623<\/span> (Red Hat <span class=\"hljs-number\">4.8<\/span><span class=\"hljs-number\">.5<\/span><span class=\"hljs-number\">-11<\/span>) (GCC) \nbuilt <span class=\"hljs-keyword\">with<\/span> OpenSSL <span class=\"hljs-number\">1.0<\/span><span class=\"hljs-number\">.1<\/span>e-fips <span class=\"hljs-number\">11<\/span> Feb <span class=\"hljs-number\">2013<\/span>\nTLS SNI support enabled\nconfigure arguments: --prefix=\/etc\/nginx --sbin-path=\/usr\/sbin\/nginx --modules-path=\/usr\/lib64\/nginx\/modules --conf-path=\/etc\/nginx\/nginx.conf --error-log-path=\/var\/log\/nginx\/error.log --http-log-path=\/var\/log\/nginx\/access.log --pid-path=\/var\/run\/nginx.pid --lock-path=\/var\/run\/nginx.lock --http-client-body-temp-path=\/var\/cache\/nginx\/client_temp --http-proxy-temp-path=\/var\/cache\/nginx\/proxy_temp --http-fastcgi-temp-path=\/var\/cache\/nginx\/fastcgi_temp --http-uwsgi-temp-path=\/var\/cache\/nginx\/uwsgi_temp --http-scgi-temp-path=\/var\/cache\/nginx\/scgi_temp --user=nginx --group=nginx --<span class=\"hljs-keyword\">with<\/span>-compat --<span class=\"hljs-keyword\">with<\/span>-file-aio --<span class=\"hljs-keyword\">with<\/span>-threads --<span class=\"hljs-keyword\">with<\/span>-http_addition_module --<span class=\"hljs-keyword\">with<\/span>-http_auth_request_module --<span class=\"hljs-keyword\">with<\/span>-http_dav_module --<span class=\"hljs-keyword\">with<\/span>-http_flv_module --<span class=\"hljs-keyword\">with<\/span>-http_gunzip_module --<span class=\"hljs-keyword\">with<\/span>-http_gzip_static_module --<span class=\"hljs-keyword\">with<\/span>-http_mp4_module --<span class=\"hljs-keyword\">with<\/span>-http_random_index_module --<span class=\"hljs-keyword\">with<\/span>-http_realip_module --<span class=\"hljs-keyword\">with<\/span>-http_secure_link_module --<span class=\"hljs-keyword\">with<\/span>-http_slice_module --<span class=\"hljs-keyword\">with<\/span>-http_ssl_module --<span class=\"hljs-keyword\">with<\/span>-http_stub_status_module --<span class=\"hljs-keyword\">with<\/span>-http_sub_module --<span class=\"hljs-keyword\">with<\/span>-http_v2_module --<span class=\"hljs-keyword\">with<\/span>-mail --<span class=\"hljs-keyword\">with<\/span>-mail_ssl_module --<span class=\"hljs-keyword\">with<\/span>-stream --<span class=\"hljs-keyword\">with<\/span>-stream_realip_module --<span class=\"hljs-keyword\">with<\/span>-stream_ssl_module --<span class=\"hljs-keyword\">with<\/span>-stream_ssl_preread_module --<span class=\"hljs-keyword\">with<\/span>-cc-opt=<span class=\"hljs-string\">'-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC'<\/span> --<span class=\"hljs-keyword\">with<\/span>-ld-opt=<span class=\"hljs-string\">'-Wl,-z,relro -Wl,-z,now -pie'<\/span>\n<\/code><\/pre>\n<p>\u901a\u8fc7 EPEL \u5b89\u88c5\u7684 Nginx<\/p>\n<pre class=\"hljs python\"><code class=\"language-bash\">root@centos<span class=\"hljs-number\">-7<\/span>-dev:~ <span class=\"hljs-comment\"># nginx -V<\/span>\nnginx version: nginx\/<span class=\"hljs-number\">1.10<\/span><span class=\"hljs-number\">.2<\/span>\nbuilt by gcc <span class=\"hljs-number\">4.8<\/span><span class=\"hljs-number\">.5<\/span> <span class=\"hljs-number\">20150623<\/span> (Red Hat <span class=\"hljs-number\">4.8<\/span><span class=\"hljs-number\">.5<\/span><span class=\"hljs-number\">-4<\/span>) (GCC) \nbuilt <span class=\"hljs-keyword\">with<\/span> OpenSSL <span class=\"hljs-number\">1.0<\/span><span class=\"hljs-number\">.1<\/span>e-fips <span class=\"hljs-number\">11<\/span> Feb <span class=\"hljs-number\">2013<\/span>\nTLS SNI support enabled\nconfigure arguments: --prefix=\/usr\/share\/nginx --sbin-path=\/usr\/sbin\/nginx --modules-path=\/usr\/lib64\/nginx\/modules --conf-path=\/etc\/nginx\/nginx.conf --error-log-path=\/var\/log\/nginx\/error.log --http-log-path=\/var\/log\/nginx\/access.log --http-client-body-temp-path=\/var\/lib\/nginx\/tmp\/client_body --http-proxy-temp-path=\/var\/lib\/nginx\/tmp\/proxy --http-fastcgi-temp-path=\/var\/lib\/nginx\/tmp\/fastcgi --http-uwsgi-temp-path=\/var\/lib\/nginx\/tmp\/uwsgi --http-scgi-temp-path=\/var\/lib\/nginx\/tmp\/scgi --pid-path=\/run\/nginx.pid --lock-path=\/run\/lock\/subsys\/nginx --user=nginx --group=nginx --<span class=\"hljs-keyword\">with<\/span>-file-aio --<span class=\"hljs-keyword\">with<\/span>-ipv6 --<span class=\"hljs-keyword\">with<\/span>-http_ssl_module --<span class=\"hljs-keyword\">with<\/span>-http_v2_module --<span class=\"hljs-keyword\">with<\/span>-http_realip_module --<span class=\"hljs-keyword\">with<\/span>-http_addition_module --<span class=\"hljs-keyword\">with<\/span>-http_xslt_module=dynamic --<span class=\"hljs-keyword\">with<\/span>-http_image_filter_module=dynamic --<span class=\"hljs-keyword\">with<\/span>-http_geoip_module=dynamic --<span class=\"hljs-keyword\">with<\/span>-http_sub_module --<span class=\"hljs-keyword\">with<\/span>-http_dav_module --<span class=\"hljs-keyword\">with<\/span>-http_flv_module --<span class=\"hljs-keyword\">with<\/span>-http_mp4_module --<span class=\"hljs-keyword\">with<\/span>-http_gunzip_module --<span class=\"hljs-keyword\">with<\/span>-http_gzip_static_module --<span class=\"hljs-keyword\">with<\/span>-http_random_index_module --<span class=\"hljs-keyword\">with<\/span>-http_secure_link_module --<span class=\"hljs-keyword\">with<\/span>-http_degradation_module --<span class=\"hljs-keyword\">with<\/span>-http_slice_module --<span class=\"hljs-keyword\">with<\/span>-http_stub_status_module --<span class=\"hljs-keyword\">with<\/span>-http_perl_module=dynamic --<span class=\"hljs-keyword\">with<\/span>-mail=dynamic --<span class=\"hljs-keyword\">with<\/span>-mail_ssl_module --<span class=\"hljs-keyword\">with<\/span>-pcre --<span class=\"hljs-keyword\">with<\/span>-pcre-jit --<span class=\"hljs-keyword\">with<\/span>-stream=dynamic --<span class=\"hljs-keyword\">with<\/span>-stream_ssl_module --<span class=\"hljs-keyword\">with<\/span>-google_perftools_module --<span class=\"hljs-keyword\">with<\/span>-debug --<span class=\"hljs-keyword\">with<\/span>-cc-opt=<span class=\"hljs-string\">'-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=\/usr\/lib\/rpm\/redhat\/redhat-hardened-cc1 -m64 -mtune=generic'<\/span> --<span class=\"hljs-keyword\">with<\/span>-ld-opt=<span class=\"hljs-string\">'-Wl,-z,relro -specs=\/usr\/lib\/rpm\/redhat\/redhat-hardened-ld -Wl,-E'<\/span>\n<\/code><\/pre>\n<p>\u4e0d\u4f46\u67d0\u4e9b\u53c2\u6570\u4e0d\u4e00\u6837\uff0c\u8ba9\u7528\u6237\u6df7\u6dc6\uff0c\u800c\u4e14 OpenSSL \u7684\u7248\u672c\u8fc7\u4f4e\uff0c\u518d\u5bf9\u6bd4\u4e0b\u6211\u4e00\u76f4\u63a8\u8350\u5728 <a href=\"https:\/\/sb.sb\/debian-9-stretch-install-nginx-php-mysql\/#h-2ondejsurnginx\">Debian 9.x<\/a> \u7528 <a href=\"https:\/\/deb.sury.org\/\">Ond\u0159ej Sur\u00fd<\/a> \u5927\u795e\u6253\u5305\u7684 Nginx \u5427<\/p>\n<pre class=\"hljs cs\"><code class=\"language-bash\">root@debian<span class=\"hljs-number\">-9<\/span>-dev ~ <span class=\"hljs-meta\"># nginx -V<\/span>\nnginx version: nginx\/<span class=\"hljs-number\">1.13<\/span><span class=\"hljs-number\">.3<\/span>\nbuilt with OpenSSL <span class=\"hljs-number\">1.1<\/span><span class=\"hljs-number\">.0<\/span>f  <span class=\"hljs-number\">25<\/span> May <span class=\"hljs-number\">2017<\/span>\nTLS SNI support enabled\nconfigure arguments: --with-cc-opt=<span class=\"hljs-string\">'-g -O2 -fdebug-prefix-map=\/build\/nginx-1.13.3=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2'<\/span> --with-ld-opt=<span class=\"hljs-string\">'-Wl,-z,relro -Wl,-z,now -fPIC'<\/span> --prefix=\/usr\/share\/nginx --conf-path=\/etc\/nginx\/nginx.conf --http-log-path=\/<span class=\"hljs-keyword\">var<\/span>\/log\/nginx\/access.log --error-log-path=\/<span class=\"hljs-keyword\">var<\/span>\/log\/nginx\/error.log --<span class=\"hljs-keyword\">lock<\/span>-path=\/<span class=\"hljs-keyword\">var<\/span>\/<span class=\"hljs-keyword\">lock<\/span>\/nginx.<span class=\"hljs-keyword\">lock<\/span> --pid-path=\/run\/nginx.pid --modules-path=\/usr\/lib\/nginx\/modules --http-client-body-temp-path=\/<span class=\"hljs-keyword\">var<\/span>\/lib\/nginx\/body --http-fastcgi-temp-path=\/<span class=\"hljs-keyword\">var<\/span>\/lib\/nginx\/fastcgi --http-proxy-temp-path=\/<span class=\"hljs-keyword\">var<\/span>\/lib\/nginx\/proxy --http-scgi-temp-path=\/<span class=\"hljs-keyword\">var<\/span>\/lib\/nginx\/scgi --http-uwsgi-temp-path=\/<span class=\"hljs-keyword\">var<\/span>\/lib\/nginx\/uwsgi --with-debug --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_flv_module --with-http_geoip_module=<span class=\"hljs-keyword\">dynamic<\/span> --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=<span class=\"hljs-keyword\">dynamic<\/span> --with-http_mp4_module --with-http_perl_module=<span class=\"hljs-keyword\">dynamic<\/span> --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module=<span class=\"hljs-keyword\">dynamic<\/span> --with-mail=<span class=\"hljs-keyword\">dynamic<\/span> --with-mail_ssl_module --with-stream=<span class=\"hljs-keyword\">dynamic<\/span> --with-stream_ssl_module --with-stream_ssl_preread_module --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/headers-more-nginx-module --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nginx-auth-pam --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nginx-cache-purge --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nginx-dav-ext-module --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nginx-development-kit --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nginx-echo --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/ngx-fancyindex --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nchan --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nginx-lua --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nginx-rtmp --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nginx-upload-progress --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/nginx-upstream-fair --<span class=\"hljs-keyword\">add<\/span>-<span class=\"hljs-keyword\">dynamic<\/span>-module=\/build\/nginx<span class=\"hljs-number\">-1.13<\/span><span class=\"hljs-number\">.3<\/span>\/debian\/modules\/ngx_http_substitutions_filter_module\n<\/code><\/pre>\n<h2 id=\"1\"><span id=\"h-1\"><\/span>1\u3001\u66f4\u65b0\u7cfb\u7edf\u5e76\u5b89\u88c5\u4f9d\u8d56\u8f6f\u4ef6<\/h2>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u66f4\u65b0\u7cfb\u7edf\uff0c\u7136\u540e\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56<\/p>\n<p>CentOS \/ RHEL \u4e0b<\/p>\n<pre class=\"hljs sql\"><code class=\"language-bash\">yum <span class=\"hljs-keyword\">install<\/span> <span class=\"hljs-keyword\">http<\/span>:\/\/dl.fedoraproject.org\/pub\/epel\/epel-<span class=\"hljs-keyword\">release<\/span>-latest<span class=\"hljs-number\">-7.<\/span>noarch.rpm\nyum <span class=\"hljs-keyword\">update<\/span>\nyum <span class=\"hljs-keyword\">upgrade<\/span>\nyum <span class=\"hljs-keyword\">install<\/span> <span class=\"hljs-keyword\">patch<\/span> libtool gcc gcc-c++ autoconf automake zlib zlib-devel pcre-devel make unzip git wget\n<\/code><\/pre>\n<p>Debian \/ Ubuntu \u4e0b<\/p>\n<pre class=\"hljs sql\"><code class=\"language-bash\">apt-get <span class=\"hljs-keyword\">update<\/span>\napt-<span class=\"hljs-keyword\">get<\/span> <span class=\"hljs-keyword\">upgrade<\/span>\napt-<span class=\"hljs-keyword\">get<\/span> <span class=\"hljs-keyword\">install<\/span> <span class=\"hljs-keyword\">patch<\/span> <span class=\"hljs-keyword\">build<\/span>-essential libpcre3 libpcre3-dev zlib1g-dev autoconf libtool automake gcc g++ make unzip git wget\n<\/code><\/pre>\n<h2 id=\"2openssl110\"><span id=\"h-2openssl110\"><\/span>2\u3001\u4e0b\u8f7d OpenSSL 1.1.0<\/h2>\n<p>\u6211\u4eec\u65b0\u5efa\u4e00\u4e2a nginx-build \u7684\u6587\u4ef6\u5939\u5e76\u8fdb\u5165<\/p>\n<pre class=\"hljs bash\"><code class=\"language-bash\">mkdir nginx-build &amp;&amp; <span class=\"hljs-built_in\">cd<\/span> nginx-build\n<\/code><\/pre>\n<p>\u7136\u540e\u4e0b\u8f7d\u6700\u65b0\u7248\u672c OpenSSL 1.1.0 \u5f53\u524d\u6700\u65b0\u7248\u4e3a 1.1.0f<\/p>\n<pre class=\"hljs nginx\"><code class=\"language-bash\"><span class=\"hljs-attribute\">wget<\/span> -c https:\/\/www.openssl.org\/source\/openssl-1.1.0f.tar.gz\ntar -zxf openssl-<span class=\"hljs-number\">1<\/span>.<span class=\"hljs-number\">1<\/span>.0f.tar.gz\n<\/code><\/pre>\n<p>\u4e3a\u4e86\u4eca\u540e\u7f16\u8bd1\u65b9\u4fbf\uff0c\u53ef\u4ee5\u91cd\u547d\u540d\u76ee\u5f55<\/p>\n<pre class=\"hljs css\"><code class=\"language-bash\"><span class=\"hljs-selector-tag\">mv<\/span> <span class=\"hljs-selector-tag\">openssl-1<\/span><span class=\"hljs-selector-class\">.1<\/span><span class=\"hljs-selector-class\">.0f<\/span> <span class=\"hljs-selector-tag\">openssl<\/span>\n<\/code><\/pre>\n<h2 id=\"3nginx1133\"><span id=\"h-3nginx1133\"><\/span>3\u3001\u4e0b\u8f7d\u5e76\u7f16\u8bd1\u5b89\u88c5 Nginx 1.13.3<\/h2>\n<p>\u4ece\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7684 Nginx \u6e90\u4ee3\u7801\u5e76\u89e3\u538b\uff0c\u8fd9\u91cc\u6211\u4eec\u5b89\u88c5 Mainline \u7248\uff0c\u76ee\u524d\u6700\u65b0\u7684\u7248\u672c\u662f 1.13.3<\/p>\n<pre class=\"hljs nginx\"><code class=\"language-bash\"><span class=\"hljs-attribute\">wget<\/span> -c http:\/\/nginx.org\/download\/nginx-1.13.3.tar.gz\ntar -zxf nginx-<span class=\"hljs-number\">1<\/span>.<span class=\"hljs-number\">13<\/span>.<span class=\"hljs-number\">3<\/span>.tar.gz\n<\/code><\/pre>\n<p>\u7136\u540e\u8fdb\u5165\u76ee\u5f55<\/p>\n<pre class=\"hljs css\"><code class=\"language-bash\"><span class=\"hljs-selector-tag\">cd<\/span> <span class=\"hljs-selector-tag\">nginx-1<\/span><span class=\"hljs-selector-class\">.13<\/span><span class=\"hljs-selector-class\">.3<\/span>\n<\/code><\/pre>\n<p>\u4e3a\u4e86\u4fdd\u6301\u548c Nginx \u5b98\u65b9\u4ed3\u5e93\u7684\u5927\u6982\u4e00\u81f4\u6027\uff0c\u6211\u4eec\u751f\u6210\u4e2a <code>\/var\/cache\/nginx<\/code> \u76ee\u5f55\uff0c\u7528\u4e8e\u9632\u6b62 Nginx \u53cd\u5411\u4ee3\u7406\u7684\u7f13\u5b58\u6587\u4ef6<\/p>\n<pre class=\"hljs cs\"><code class=\"language-bash\">mkdir -p \/<span class=\"hljs-keyword\">var<\/span>\/cache\/nginx\n<\/code><\/pre>\n<p>\u65b0\u5efa\u4e00\u4e2a nginx \u7684\u7528\u6237<\/p>\n<pre class=\"hljs nginx\"><code class=\"language-bash\"><span class=\"hljs-attribute\">useradd<\/span> nginx\n<\/code><\/pre>\n<p>\u7136\u540e\u6839\u636e\u81ea\u5df1\u7684\u4e8b\u60c5\u60c5\u51b5\u6765\u7f16\u8bd1\u6a21\u5757\uff0c\u8fd9\u91cc\u6211\u4eec\u60f3\u7f16\u8bd1\u5982\u4e0b\u6a21\u5757\uff0c\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u5220\u6539<\/p>\n<pre class=\"hljs javascript\"><code>http_v2_module\nhttp_ssl_module\nhttp_gzip_static_module\n<span class=\"hljs-keyword\">with<\/span>-http_realip_module\n<\/code><\/pre>\n<p>\u7136\u540e\u914d\u7f6e\u7f16\u8bd1<\/p>\n<pre class=\"hljs ruby\"><code class=\"language-bash\">.\/configure --with-openssl=..\/openssl --prefix=<span class=\"hljs-regexp\">\/etc\/nginx<\/span> --sbin-path=<span class=\"hljs-regexp\">\/usr\/sbin<\/span><span class=\"hljs-regexp\">\/nginx --modules-path=\/usr<\/span><span class=\"hljs-regexp\">\/lib64\/nginx<\/span><span class=\"hljs-regexp\">\/modules --conf-path=\/etc<\/span><span class=\"hljs-regexp\">\/nginx\/nginx<\/span>.conf --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --error-log-path=<span class=\"hljs-regexp\">\/var\/log<\/span><span class=\"hljs-regexp\">\/nginx\/error<\/span>.log --http-log-path=<span class=\"hljs-regexp\">\/var\/log<\/span><span class=\"hljs-regexp\">\/nginx\/access<\/span>.log --pid-path=<span class=\"hljs-regexp\">\/var\/run<\/span><span class=\"hljs-regexp\">\/nginx.pid --lock-path=\/var<\/span><span class=\"hljs-regexp\">\/run\/nginx<\/span>.lock --http-client-body-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/client<\/span>_temp --http-proxy-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/proxy<\/span>_temp --http-fastcgi-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/fastcgi<\/span>_temp --http-uwsgi-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/uwsgi<\/span>_temp --http-scgi-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/scgi<\/span>_temp --user=nginx --group=nginx\n<\/code><\/pre>\n<p>\u6eda\u5b8c\u5c4f\u5e55\u540e\u4f1a\u63d0\u793a<\/p>\n<pre class=\"hljs cpp\"><code>Configuration summary\n  + <span class=\"hljs-keyword\">using<\/span> system PCRE library\n  + <span class=\"hljs-keyword\">using<\/span> OpenSSL library: ..\/openssl\n  + <span class=\"hljs-keyword\">using<\/span> system zlib library\n\n  nginx path prefix: <span class=\"hljs-string\">\"\/etc\/nginx\"<\/span>\n  nginx binary file: <span class=\"hljs-string\">\"\/usr\/sbin\/nginx\"<\/span>\n  nginx modules path: <span class=\"hljs-string\">\"\/usr\/lib64\/nginx\/modules\"<\/span>\n  nginx configuration prefix: <span class=\"hljs-string\">\"\/etc\/nginx\"<\/span>\n  nginx configuration file: <span class=\"hljs-string\">\"\/etc\/nginx\/nginx.conf\"<\/span>\n  nginx pid file: <span class=\"hljs-string\">\"\/var\/run\/nginx.pid\"<\/span>\n  nginx error <span class=\"hljs-built_in\">log<\/span> file: <span class=\"hljs-string\">\"\/var\/log\/nginx\/error.log\"<\/span>\n  nginx http access <span class=\"hljs-built_in\">log<\/span> file: <span class=\"hljs-string\">\"\/var\/log\/nginx\/access.log\"<\/span>\n  nginx http client request body temporary files: <span class=\"hljs-string\">\"\/var\/cache\/nginx\/client_temp\"<\/span>\n  nginx http proxy temporary files: <span class=\"hljs-string\">\"\/var\/cache\/nginx\/proxy_temp\"<\/span>\n  nginx http fastcgi temporary files: <span class=\"hljs-string\">\"\/var\/cache\/nginx\/fastcgi_temp\"<\/span>\n  nginx http uwsgi temporary files: <span class=\"hljs-string\">\"\/var\/cache\/nginx\/uwsgi_temp\"<\/span>\n  nginx http scgi temporary files: <span class=\"hljs-string\">\"\/var\/cache\/nginx\/scgi_temp\"<\/span>\n<\/code><\/pre>\n<p>\u68c0\u67e5\u4e00\u4e0b\u662f\u5426\u548c\u4f60\u60f3\u8981\u7684\u914d\u7f6e\u53c2\u6570\u4e00\u81f4\uff0c\u6ca1\u95ee\u9898\u7684\u8bdd\u76f4\u63a5\u7f16\u8bd1\u5b89\u88c5<\/p>\n<pre class=\"hljs nginx\"><code class=\"language-bash\"><span class=\"hljs-attribute\">make<\/span> &amp;&amp; make install\n<\/code><\/pre>\n<p>\u7b49\u7ec8\u7aef\u7684\u5c4f\u5e55\u6eda\u5b8c\u4e4b\u540e\u5c31\u5b89\u88c5\u5b8c\u6bd5\u4e86\uff0c\u6b64\u65f6\u5e94\u8be5\u4f1a\u6709 <code>\/sbin\/nginx<\/code> \u548c <code>\/usr\/sbin\/nginx<\/code> \u8fd9\u4e24\u4e2a\u4e00\u6a21\u4e00\u6837\u7684\u6587\u4ef6\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4f18\u5148\u7ea7\u540e\u8005\u9ad8<\/p>\n<pre class=\"hljs coffeescript\"><code class=\"language-bash\">[root@centos<span class=\"hljs-number\">-7<\/span>-dev ~]<span class=\"hljs-comment\"># ll \/sbin\/nginx<\/span>\n-rwxr-xr-x. <span class=\"hljs-number\">1<\/span> root root <span class=\"hljs-number\">7342960<\/span> Aug  <span class=\"hljs-number\">6<\/span> <span class=\"hljs-number\">17<\/span>:<span class=\"hljs-number\">01<\/span> \/sbin\/nginx\n[root@centos<span class=\"hljs-number\">-7<\/span>-dev ~]<span class=\"hljs-comment\"># ll \/usr\/sbin\/nginx<\/span>\n-rwxr-xr-x. <span class=\"hljs-number\">1<\/span> root root <span class=\"hljs-number\">7342960<\/span> Aug  <span class=\"hljs-number\">6<\/span> <span class=\"hljs-number\">17<\/span>:<span class=\"hljs-number\">01<\/span> \/usr\/sbin\/nginx\n\n[root@centos<span class=\"hljs-number\">-7<\/span>-dev ~]<span class=\"hljs-comment\"># sha256sum \/sbin\/nginx<\/span>\n<span class=\"hljs-number\">0<\/span>d51039d118fdca6ca4d6b0dec132641f3ee3e0f57492fe5edf72713eb5b7488  \/sbin\/nginx\n[root@centos<span class=\"hljs-number\">-7<\/span>-dev ~]<span class=\"hljs-comment\"># sha256sum \/usr\/sbin\/nginx<\/span>\n<span class=\"hljs-number\">0<\/span>d51039d118fdca6ca4d6b0dec132641f3ee3e0f57492fe5edf72713eb5b7488  \/usr\/sbin\/nginx\n\n[root@centos<span class=\"hljs-number\">-7<\/span>-dev ~]<span class=\"hljs-comment\"># which nginx<\/span>\n\/usr\/sbin\/nginx\n<\/code><\/pre>\n<p>\u524d\u8005\u662f Nginx \u6e90\u7801\u81ea\u5e26\uff0c\u540e\u8005\u662f\u6211\u4eec\u6307\u5b9a\u7684\u76ee\u5f55\uff0c\u8fd9\u65f6\u5019\u770b\u770b\u81ea\u5df1\u7f16\u8bd1\u7684 Nginx \u7248\u672c\uff0c\u5e94\u8be5\u5df2\u7ecf\u662f\u6700\u65b0\u7248\u4e86<\/p>\n<pre class=\"hljs ruby\"><code class=\"language-bash\">[root@centos-<span class=\"hljs-number\">7<\/span>-dev ~]<span class=\"hljs-comment\"># nginx -V<\/span>\nnginx <span class=\"hljs-symbol\">version:<\/span> nginx\/<span class=\"hljs-number\">1.13<\/span>.<span class=\"hljs-number\">3<\/span>\nbuilt by gcc <span class=\"hljs-number\">4.8<\/span>.<span class=\"hljs-number\">5<\/span> <span class=\"hljs-number\">20150623<\/span> (Red Hat <span class=\"hljs-number\">4.8<\/span>.<span class=\"hljs-number\">5<\/span>-<span class=\"hljs-number\">11<\/span>) (GCC) \nbuilt with OpenSSL <span class=\"hljs-number\">1.1<\/span>.0f  <span class=\"hljs-number\">25<\/span> May <span class=\"hljs-number\">2017<\/span>\nTLS SNI support enabled\nconfigure <span class=\"hljs-symbol\">arguments:<\/span> --with-openssl=..\/openssl --prefix=<span class=\"hljs-regexp\">\/etc\/nginx<\/span> --sbin-path=<span class=\"hljs-regexp\">\/usr\/sbin<\/span><span class=\"hljs-regexp\">\/nginx --modules-path=\/usr<\/span><span class=\"hljs-regexp\">\/lib64\/nginx<\/span><span class=\"hljs-regexp\">\/modules --conf-path=\/etc<\/span><span class=\"hljs-regexp\">\/nginx\/nginx<\/span>.conf --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --error-log-path=<span class=\"hljs-regexp\">\/var\/log<\/span><span class=\"hljs-regexp\">\/nginx\/error<\/span>.log --http-log-path=<span class=\"hljs-regexp\">\/var\/log<\/span><span class=\"hljs-regexp\">\/nginx\/access<\/span>.log --pid-path=<span class=\"hljs-regexp\">\/var\/run<\/span><span class=\"hljs-regexp\">\/nginx.pid --lock-path=\/var<\/span><span class=\"hljs-regexp\">\/run\/nginx<\/span>.lock --http-client-body-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/client<\/span>_temp --http-proxy-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/proxy<\/span>_temp --http-fastcgi-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/fastcgi<\/span>_temp --http-uwsgi-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/uwsgi<\/span>_temp --http-scgi-temp-path=<span class=\"hljs-regexp\">\/var\/cache<\/span><span class=\"hljs-regexp\">\/nginx\/scgi<\/span>_temp --user=nginx --group=nginx\n<\/code><\/pre>\n<p>\u6211\u4eec\u4e5f\u53ef\u4ee5\u628a Nginx \u52a0\u5165\u7cfb\u7edf\u670d\u52a1<\/p>\n<pre class=\"hljs makefile\"><code class=\"language-bash\">cat &gt;&gt; \/usr\/lib\/systemd\/system\/nginx.service  &lt;&lt; EOF\n[Unit]\nDescription=nginx - high performance web server\nDocumentation=http:\/\/nginx.org\/en\/docs\/\nAfter=network-online.target remote-fs.target nss-lookup.target\nWants=network-online.target\n \n[Service]\nType=forking\nPIDFile=\/var\/run\/nginx.pid\nExecStartPre=\/usr\/sbin\/nginx -t -c \/etc\/nginx\/nginx.conf\nExecStart=\/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf\nExecReload=\/bin\/kill -s HUP $MAINPID\nExecStop=\/bin\/kill -s TERM $MAINPID\n \n[Install]\nWantedBy=multi-user.target\nEOF\n<\/code><\/pre>\n<p>\u7136\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528 <code>systemctl start nginx<\/code> \u547d\u4ee4\u542f\u52a8 Nginx \u4e86\uff0c\u5982\u679c\u51fa\u73b0\u95ee\u9898\u8bf7\u4f7f\u7528 <code>systemctl status nginx<\/code> \u547d\u4ee4\u67e5\u770b\u6216\u8005 <code>nginx -t<\/code> \u547d\u4ee4\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u542f\u52a8\u540e\u770b\u4e00\u4e0b\u9ed8\u8ba4\u7684\u7f51\u7ad9\u662f\u5426\u53ef\u4ee5\u6253\u5f00\u4e86<\/p>\n<pre class=\"hljs xml\"><code class=\"language-bash\">[root@centos-7-dev ~]# curl http:\/\/localhost\/\n<span class=\"hljs-meta\">&lt;!DOCTYPE html&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>Welcome to nginx!<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\n    <span class=\"hljs-selector-tag\">body<\/span> {\n        <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">35em<\/span>;\n        <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">0<\/span> auto;\n        <span class=\"hljs-attribute\">font-family<\/span>: Tahoma, Verdana, Arial, sans-serif;\n    }\n<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>Welcome to nginx!<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span>If you see this page, the nginx web server is successfully installed and\nworking. Further configuration is required.<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span>For online documentation and support please refer to\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"http:\/\/nginx.org\/\"<\/span>&gt;<\/span>nginx.org<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">a<\/span>&gt;<\/span>.<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">br<\/span>\/&gt;<\/span>\nCommercial support is available at\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"http:\/\/nginx.com\/\"<\/span>&gt;<\/span>nginx.com<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">a<\/span>&gt;<\/span>.<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">em<\/span>&gt;<\/span>Thank you for using nginx.<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">em<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span>\n<\/code><\/pre>\n<p>\u7531\u4e8e\u6211\u4eec\u7f16\u8bd1\u65f6\u6307\u5b9a\u4e86\u8fd0\u884c\u7684\u7528\u6237\u548c pid \u6587\u4ef6\uff0c\u6240\u4ee5\u4e5f\u53ef\u4ee5\u4fee\u6539\u4e00\u4e0b <code>\/etc\/nginx\/nginx.conf<\/code> \u5934\u90e8\u52a0\u5165<\/p>\n<pre class=\"hljs nginx\"><code class=\"language-bash\"><span class=\"hljs-attribute\">user<\/span> nginx;\n<span class=\"hljs-attribute\">pid<\/span> \/var\/run\/nginx.pid;\n<\/code><\/pre>\n<p>\u5f53\u7136\u7559\u7a7a\u6216\u8005\u81ea\u5df1\u4fee\u6539\u6210\u5176\u4ed6\u7528\u6237\u548c\u6587\u4ef6\u4e5f\u662f\u6ca1\u95ee\u9898\u7684<\/p>\n<p>\u5176\u4ed6 Nginx \u914d\u7f6e\u7684\u7528\u6cd5\u6211\u4eec\u4f1a\u5728\u4ee5\u540e\u7684\u6587\u7ae0\u4e2d\u6162\u6162\u4ecb\u7ecd<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u6240\u4ee5\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u5728 CentOS 7.x \/ RHEL 7.x \u4e0b\u7f16\u8bd1\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684 Nginx [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[10],"tags":[64,201,202,203,229],"class_list":["post-118","post","type-post","status-publish","format-aside","hentry","category-hardware","tag-centos-7-x","tag-nginx","tag-nginx-1-13-3","tag-nginx1-12-1","tag-openssl","post_format-post-format-aside"],"_links":{"self":[{"href":"https:\/\/myya.net\/index.php\/wp-json\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myya.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myya.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myya.net\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/myya.net\/index.php\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":0,"href":"https:\/\/myya.net\/index.php\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"wp:attachment":[{"href":"https:\/\/myya.net\/index.php\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myya.net\/index.php\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myya.net\/index.php\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}