{"id":32694,"date":"2023-04-06T16:28:40","date_gmt":"2023-02-28T23:07:11","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/"},"modified":"2024-04-29T22:13:21","modified_gmt":"2024-04-29T14:13:21","slug":"%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/","title":{"rendered":"\u4f7f\u7528nginx-build\u5728LAMP\u73af\u5883\u4e2d\u6784\u5efanginx"},"content":{"rendered":"<p>\u6211\u5df2\u7ecf\u5efa\u7acb\u4e86\u4e00\u4e2a\u5305\u542bApache2 + MariaDB + PHP7\u7684\u73af\u5883\uff0c\u60f3\u8981\u5c06nginx\u914d\u7f6e\u4e3a\u4e00\u4e2aWeb\u670d\u52a1\u5668\u5e76\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002<br \/>\n\u5c3d\u7ba1yum install nginx\u5f88\u65b9\u4fbf\uff0c\u4f46\u7531\u4e8e\u6ca1\u6709\u5b89\u88c5ngx-cache-purge\u548cngx_pagespeed\u7b49\u7b2c\u4e09\u65b9\u6a21\u5757\uff0c\u6240\u4ee5\u6211\u5c06\u4f7f\u7528nginx-build\u3002<\/p>\n<h1>\u5f15\u5165nginx-build<\/h1>\n<p>\u521b\u5efa\u4e00\u4e2a nginx \u7528\u6237<\/p>\n<pre class=\"post-pre\"><code>$ useradd -s \/sbin\/nologin nginx \r\n<\/code><\/pre>\n<p>\u6dfb\u52a0\u7f13\u5b58\u76ee\u5f55<\/p>\n<pre class=\"post-pre\"><code>$ sudo mkdir \/var\/cache\/nginx\r\n$ sudo chown nginx:nginx \/var\/cache\/nginx\r\n<\/code><\/pre>\n<p>\u968f\u610f\u521b\u5efa\u4e00\u4e2a\u76ee\u5f55\u6765\u5b58\u653e nginx-build \u7684\u5de5\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ mkdir -p ~\/nginx-build\r\n$ cd ~\/nginx-build\r\n<\/code><\/pre>\n<p>\u5982\u679c\u6ca1\u6709\u5b89\u88c5Go\u8bed\u8a00\uff0c\u5219\u4eceGit\u4e2d\u4e0b\u8f7d\u5df2\u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code>Go\u8a00\u8a9e\u74b0\u5883\u6709\u308a\r\n$ go get -u github.com\/cubicdaiya\/nginx-build\r\n\r\nGo\u8a00\u8a9e\u74b0\u5883\u7121\u3057\r\n$ wget https:\/\/github.com\/cubicdaiya\/nginx-build\/releases\/download\/v0.10.0\/nginx-build-linux-amd64-0.10.0.tar.gz\r\n$ tar zxvf nginx-build-linux-amd64-0.10.0.tar.gz\r\n$ rm -f nginx-build-linux-amd64-0.10.0.tar.gz\r\n<\/code><\/pre>\n<h2>\u6dfb\u52a0\u7528\u4e8e\u7b2c\u4e09\u65b9\u6a21\u5757\u7684\u914d\u7f6e\u6587\u4ef6<\/h2>\n<p>\u53ea\u9700\u4e00\u4e2a\u9009\u62e9\uff0c\u7528\u4e2d\u6587\u5c06\u4ee5\u4e0b\u5185\u5bb9\u8868\u8fbe\u51fa\u6765\uff1a<br \/>\n\u5982\u679c\u540c\u65f6\u4f7f\u7528 ngx-cache-purge \u548c ngx_pagespeed \u8fd9\u4e24\u79cd\u65b9\u5f0f\u7684\u8bdd\u3002<\/p>\n<pre class=\"post-pre\"><code>$ vi ~\/nginx-build\/modules3rd.ini\r\n--\r\n\r\n[ngx_cache_purge]\r\nform=git\r\nurl=https:\/\/github.com\/FRiCKLE\/ngx_cache_purge.git\r\nrev=v2.3\r\n\r\n[ngx_pagespeed]\r\nfrom=git\r\nurl=https:\/\/github.com\/pagespeed\/ngx_pagespeed.git\r\nrev=v1.12.34.2-stable\r\n<\/code><\/pre>\n<h2>\u6dfb\u52a0configure\u811a\u672c<\/h2>\n<p>\u8bf7\u6839\u636e\u9700\u8981\u8fdb\u884c\u76f8\u5e94\u4fee\u6539\uff08\u4e0b\u9762\u7684\u5185\u5bb9\u4e0eyum\u7248\u5b89\u88c5\u6a21\u5757\u51e0\u4e4e\u76f8\u540c\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>$ vi ~\/nginx-build\/configure.sh\r\n--\r\n#!\/bin\/sh\r\n\r\n.\/configure \\\r\n--user=nginx \\\r\n--group=nginx \\\r\n--with-pcre=$HOME\/nginx-build\/work\/nginx\/1.13.1\/pcre-8.40 \\\r\n--with-openssl=$HOME\/nginx-build\/work\/nginx\/1.13.1\/openssl-1.0.2l \\\r\n--with-zlib=$HOME\/nginx-build\/work\/nginx\/1.13.1\/zlib-1.2.11 \\\r\n--add-module=$HOME\/nginx-build\/work\/nginx\/1.13.1\/ngx_cache_purge \\\r\n--with-file-aio \\\r\n--with-ipv6 \\\r\n--with-http_ssl_module \\\r\n--with-http_v2_module \\\r\n--with-http_realip_module \\\r\n--with-http_addition_module \\\r\n--with-http_xslt_module=dynamic \\\r\n--with-http_image_filter_module=dynamic \\\r\n--with-http_geoip_module=dynamic \\\r\n--with-http_sub_module \\\r\n--with-http_dav_module \\\r\n--with-http_flv_module \\\r\n--with-http_mp4_module \\\r\n--with-http_gunzip_module \\\r\n--with-http_gzip_static_module \\\r\n--with-http_random_index_module \\\r\n--with-http_secure_link_module \\\r\n--with-http_degradation_module \\\r\n--with-http_slice_module \\\r\n--with-http_stub_status_module \\\r\n--with-http_perl_module=dynamic \\\r\n--with-mail=dynamic \\\r\n--with-mail_ssl_module \\\r\n--with-pcre-jit \\\r\n--with-stream=dynamic \\\r\n--with-stream_ssl_module \\\r\n--with-google_perftools_module \\\r\n--with-debug \\\r\n--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' \\\r\n--with-ld-opt=-Wl,-E \\\r\n<\/code><\/pre>\n<h2>\u6dfb\u52a0\u4f9d\u8d56\u5e93\u5e76\u6784\u5efa<\/h2>\n<pre class=\"post-pre\"><code>$ ~\/nginx-build\/nginx-build \\\r\n-d work \\\r\n-pcre \\\r\n-zlib \\\r\n-openssl \\\r\n-m ~\/nginx-build\/modules3rd.ini\r\n-c ~\/nginx-build\/configure.sh\r\n<\/code><\/pre>\n<p>\u5982\u679c\u65e0\u6cd5\u4e0b\u8f7d\u5e93\u5e76\u4e14\u5bfc\u81f4\u5d29\u6e83\u7684\u60c5\u51b5\u53d1\u751f\uff0c\u5c06\u5904\u7406\u5206\u5f00\u5c06\u4f1a\u83b7\u5f97\u826f\u597d\u7684\u7ed3\u679c\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ~\/nginx-build\/nginx-build -d work -pcre -zlib -openssl               \u2190 \u4f9d\u5b58\u30e9\u30a4\u30d6\u30e9\u30ea\r\n$ ~\/nginx-build\/nginx-build -d work -m ~\/nginx-build\/modules3rd.ini    \u2190 \u30b5\u30fc\u30c9\u30e2\u30b8\u30e5\u30fc\u30eb\r\n$ ~\/nginx-build\/nginx-build -d work -c ~\/nginx-build\/configure.sh      \u2190 \u30b3\u30f3\u30d5\u30a3\u30b0\r\n<\/code><\/pre>\n<p>\u5982\u679c\u51fa\u73b0HTTP rewrite\u6a21\u5757\u9519\u8bef\uff0c<\/p>\n<pre class=\"post-pre\"><code>.\/configure: error: the HTTP rewrite module requires the PCRE library.\r\nYou can either disable the module by using --without-http_rewrite_module\r\noption, or install the PCRE library into the system, or build the PCRE library\r\nstatically from the source with nginx by using --with-pcre=&lt;path&gt; option.\r\n\r\n$ sudo yum -y install pcre-devel\r\n<\/code><\/pre>\n<p>\u5f53\u9047\u5230HTTP gzip\u6a21\u5757\u7684\u9519\u8bef\u65f6\uff0c<\/p>\n<pre class=\"post-pre\"><code>.\/configure: error: the HTTP gzip module requires the zlib library.\r\nYou can either disable th module by using --without-http_gzip_module\r\noption, or install the zlib library into the system, or build the zlib library\r\nstatically from the source with nginx by using --with-zlib=&lt;path&gt; option.\r\n\r\n$ sudo yum -y install zlib-devel\r\n<\/code><\/pre>\n<p>\u5982\u679c\u51fa\u73b0HTTP XSLT\u6a21\u5757\u7684\u9519\u8bef\uff0c<\/p>\n<pre class=\"post-pre\"><code>.\/configure: error: the HTTP XSLT module requires the libxml2\/libxslt\r\nlibraries. You can either do not enable the module or install the libraries.\r\n\r\n$ sudo yum -y install libxslt-devel\r\n<\/code><\/pre>\n<p>\u5f53HTTP\u56fe\u50cf\u8fc7\u6ee4\u5668\u6a21\u5757\u51fa\u73b0\u9519\u8bef\u65f6\uff0c<\/p>\n<pre class=\"post-pre\"><code>.\/configure: error: the HTTP image filter module requires the GD library.\r\nYou can either do not enable the module or install the libraries.\r\n\r\n$ sudo yum -y install gd-devel\r\n<\/code><\/pre>\n<p>\u5982\u679c\u51fa\u73b0perl\u6a21\u5757\u7684\u9519\u8bef\uff0c\u8bf7<\/p>\n<pre class=\"post-pre\"><code>.\/configure: error: perl module ExtUtils::Embed is required\r\n\r\n$ sudo yum -y install perl-ExtUtils-Embed\r\n<\/code><\/pre>\n<p>\u5982\u679c\u9047\u5230GeoIP\u6a21\u5757\u7684\u9519\u8bef\uff0c<\/p>\n<pre class=\"post-pre\"><code>.\/configure: error: the GeoIP module requires the GeoIP library.\r\nYou can either do not enable the module or install the library.\r\n\r\n$ sudo yum -y install GeoIP-devel\r\n<\/code><\/pre>\n<p>\u5982\u679c\u9047\u5230Google perftools\u6a21\u5757\u7684\u9519\u8bef\uff0c\u8bf7\u5904\u7406\u3002<\/p>\n<pre class=\"post-pre\"><code>.\/configure: error: the Google perftools module requires the Google perftools\r\nlibrary. You can either do not enable the module or install the library.\r\n\r\n$ sudo yum -y install gperftools-devel\r\n<\/code><\/pre>\n<p>\u5c06\u4ee5\u4e0a\u63d0\u5230\u7684\u6a21\u5757\u4e0d\u8db3\u90e8\u5206\u4e00\u6b21\u6027\u5b89\u88c5\u5b8c\u6210\u3002<\/p>\n<pre class=\"post-pre\"><code>$ sudo yum -y install pcre-devel zlib-devel gd-devel libxslt-devel perl-ExtUtils-Embed GeoIP-devel gperftools-devel\r\n<\/code><\/pre>\n<p>\u5f53\u5c06ngx_pagespeed\u6dfb\u52a0\u4e3a\u7b2c\u4e09\u65b9\u7ec4\u4ef6\u65f6\uff0c\u4f1a\u51fa\u73b0\u4ee5\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre class=\"post-pre\"><code>  You need to separately download the pagespeed library:\r\n     $ cd \/home\/vagrant\/nginx-build\/work\/nginx\/1.13.1\/ngx_pagespeed\r\n     $ wget https:\/\/dl.google.com\/dl\/page-speed\/psol\/1.12.34.2-x64.tar.gz\r\n     $ tar -xzvf 1.12.34.2-x64.tar.gz # expands to psol\/\r\n<\/code><\/pre>\n<p>\u6309\u7167\u6307\u793a\u6267\u884c\u5e76\u91cd\u65b0\u6784\u5efa\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ~\/nginx-build\/nginx-build -d work -c ~\/nginx-build\/configure.sh\r\n\r\n\u7565\r\n\r\n$ Complete building nginx!\r\n\r\nnginx version: nginx\/1.13.1\r\nbuilt by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) \r\nbuilt with OpenSSL 1.0.2l  25 May 2017\r\nTLS SNI support enabled\r\nconfigure arguments: --user=nginx --group=nginx --with-pcre=\/home\/vagrant\/nginx-build\/work\/nginx\/1.13.1\/pcre-8.40 --with-openssl=\/home\/vagrant\/nginx-build\/work\/nginx\/1.13.1\/openssl-1.0.2l --with-zlib=\/home\/vagrant\/nginx-build\/work\/nginx\/1.13.1\/zlib-1.2.11 --add-module=\/home\/vagrant\/nginx-build\/work\/nginx\/1.13.1\/ngx_cache_purge --add-module=\/home\/vagrant\/nginx-build\/work\/nginx\/1.13.1\/ngx_pagespeed --with-http_ssl_module --with-http_v2_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_stub_status_module --with-http_sub_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module\r\n\r\n$ Enter the following command for install nginx.\r\n\r\n   $ cd work\/nginx\/1.13.1\/nginx-1.13.1\r\n   $ sudo make install\r\n\r\n<\/code><\/pre>\n<p>\u6309\u7167\u6307\u793a\u8fd0\u884cmake\u547d\u4ee4\u65f6\uff0cnginx-build\u6210\u529f\u6784\u5efa\u3002<br \/>\n\u5df2\u5728\/usr\/local\/nginx\u6dfb\u52a0\u4e86nginx\u6587\u4ef6\u5939\u3002<\/p>\n<pre class=\"post-pre\"><code>$ ls -l \/usr\/local\/nginx\r\n<\/code><\/pre>\n<p>\u9519\u8bef\u68c0\u67e5<\/p>\n<pre class=\"post-pre\"><code>$ sudo \/usr\/local\/nginx\/sbin\/nginx -t\r\n<\/code><\/pre>\n<p>\u68c0\u67e5\u662f\u5426\u5df2\u7ecf\u6784\u5efa\u6a21\u5757\u3002<\/p>\n<pre class=\"post-pre\"><code>$ sudo \/usr\/local\/nginx\/sbin\/nginx -V\r\n<\/code><\/pre>\n<h1>\u670d\u52a1\u6ce8\u518c<\/h1>\n<pre class=\"post-pre\"><code>$ sudo vi \/lib\/systemd\/system\/nginx.service\r\n--\r\n[Unit]\r\nDescription=The NGINX HTTP and reverse proxy server\r\nAfter=syslog.target network.target remote-fs.target nss-lookup.target\r\n\r\n[Service]\r\nType=forking\r\nPIDFile=\/usr\/local\/nginx\/logs\/nginx.pid\r\nExecStartPre=\/usr\/local\/nginx\/sbin\/nginx -t\r\nExecStart=\/usr\/local\/nginx\/sbin\/nginx\r\nExecReload=\/bin\/kill -s HUP $MAINPID\r\nExecStop=\/bin\/kill -s QUIT $MAINPID\r\nPrivateTmp=true\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/code><\/pre>\n<p>\u786e\u8ba4\u670d\u52a1\u7684\u8fd0\u884c\u72b6\u6001<\/p>\n<pre class=\"post-pre\"><code>$ sudo systemctl status nginx.service\r\n\u25cf nginx.service - The NGINX HTTP and reverse proxy server\r\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/nginx.service; disabled; vendor preset: disabled)\r\n   Active: inactive (dead)\r\n<\/code><\/pre>\n<h1>\u5b89\u88c5PHP-FPM<\/h1>\n<pre class=\"post-pre\"><code>$ sudo yum -y install php-fpm\r\n<\/code><\/pre>\n<h2>\u66f4\u6539PHP-FPM\u7684\u914d\u7f6e<\/h2>\n<p>\u5c06\u4f4d\u4e8e\/etc\/php-fpm.d\/www.conf\u6587\u4ef6\u4e2d\u7684user\u548cgroup\u66f4\u6539\u4e3anginx\u3002<\/p>\n<pre class=\"post-pre\"><code>$ sudo vi \/etc\/php-fpm.d\/www.conf\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"gd\">- user = apache\r\n- group = apache\r\n<\/span><span class=\"gi\">+ user = nginx\r\n+ group = nginx\r\n<\/span><\/code><\/pre>\n<h2>\u5c06\u542f\u52a8\u6216\u91cd\u65b0\u542f\u52a8PHP-FPM\u3002<\/h2>\n<pre class=\"post-pre\"><code>$ sudo systemctl enable php-fpm\r\n$ sudo systemctl restart php-fpm\r\n<\/code><\/pre>\n<h1>\u4fee\u6539Nginx\u7684\u914d\u7f6e<\/h1>\n<pre class=\"post-pre\"><code>$ sudo vi \/usr\/local\/nginx\/conf\/nginx.conf\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>\r\n<span class=\"k\">user<\/span>  <span class=\"s\">nginx<\/span><span class=\"p\">;<\/span>\r\n<span class=\"k\">worker_processes<\/span>  <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\r\n\r\n<span class=\"k\">error_log<\/span>  <span class=\"n\">\/var\/log\/nginx\/error.log<\/span> <span class=\"s\">warn<\/span><span class=\"p\">;<\/span>\r\n<span class=\"k\">pid<\/span>        <span class=\"n\">\/usr\/local\/nginx\/logs\/nginx.pid<\/span><span class=\"p\">;<\/span>\r\n\r\n\r\n<span class=\"k\">events<\/span> <span class=\"p\">{<\/span>\r\n  <span class=\"kn\">worker_connections<\/span>  <span class=\"mi\">1024<\/span><span class=\"p\">;<\/span>\r\n<span class=\"p\">}<\/span>\r\n\r\n\r\n<span class=\"k\">http<\/span> <span class=\"p\">{<\/span>\r\n  <span class=\"kn\">include<\/span>       <span class=\"s\">mime.types<\/span><span class=\"p\">;<\/span>\r\n  <span class=\"kn\">default_type<\/span>  <span class=\"nc\">application\/octet-stream<\/span><span class=\"p\">;<\/span>\r\n\r\n  <span class=\"kn\">log_format<\/span>  <span class=\"s\">main<\/span>  <span class=\"s\">'<\/span><span class=\"nv\">$remote_addr<\/span> <span class=\"s\">-<\/span> <span class=\"nv\">$remote_user<\/span> <span class=\"s\">[<\/span><span class=\"nv\">$time_local<\/span><span class=\"s\">]<\/span> <span class=\"s\">\"<\/span><span class=\"nv\">$request<\/span><span class=\"s\">\"<\/span> <span class=\"s\">'<\/span>\r\n                    <span class=\"s\">'<\/span><span class=\"nv\">$status<\/span> <span class=\"nv\">$body_bytes_sent<\/span> <span class=\"s\">\"<\/span><span class=\"nv\">$http_referer<\/span><span class=\"s\">\"<\/span> <span class=\"s\">'<\/span>\r\n                    <span class=\"s\">'\"<\/span><span class=\"nv\">$http_user_agent<\/span><span class=\"s\">\"<\/span> <span class=\"s\">\"<\/span><span class=\"nv\">$http_x_forwarded_for<\/span><span class=\"s\">\"'<\/span><span class=\"p\">;<\/span>\r\n\r\n  <span class=\"kn\">access_log<\/span>  <span class=\"n\">\/var\/log\/nginx\/access.log<\/span>  <span class=\"s\">main<\/span><span class=\"p\">;<\/span>\r\n\r\n  <span class=\"kn\">sendfile<\/span>        <span class=\"no\">on<\/span><span class=\"p\">;<\/span>\r\n  <span class=\"c1\">#tcp_nopush     on;<\/span>\r\n\r\n  <span class=\"kn\">keepalive_timeout<\/span>  <span class=\"mi\">65<\/span><span class=\"p\">;<\/span>\r\n\r\n  <span class=\"c1\">#gzip  on;<\/span>\r\n\r\n  <span class=\"kn\">proxy_cache_path<\/span> <span class=\"n\">\/var\/cache\/nginx<\/span> <span class=\"s\">levels=1:2<\/span> <span class=\"s\">keys_zone=czone:4m<\/span> <span class=\"s\">max_size=50m<\/span> <span class=\"s\">inactive=120m<\/span><span class=\"p\">;<\/span>\r\n  <span class=\"kn\">proxy_cache<\/span> <span class=\"s\">czone<\/span><span class=\"p\">;<\/span>\r\n  <span class=\"c1\">#proxy_temp_path  \/var\/cache\/nginx_tmp;<\/span>\r\n\r\n  <span class=\"kn\">include<\/span> <span class=\"n\">\/usr\/local\/nginx\/conf.d\/*.conf<\/span><span class=\"p\">;<\/span>\r\n<span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>$ sudo mkdir \/usr\/local\/nginx\/conf.d\r\n$ sudo vi    \/usr\/local\/nginx\/conf.d\/default.conf\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>server {\r\n    listen       80;\r\n    server_name  localhost;\r\n\r\n    location \/ {\r\n        root   \/var\/www\/html;\r\n        index  index.html index.htm index.php;\r\n    }\r\n\r\n    location ~ \\.php$ {\r\n        root           \/var\/www\/html;\r\n        fastcgi_pass   127.0.0.1:9000;\r\n        fastcgi_index  index.php;\r\n        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;\r\n        include        fastcgi_params;\r\n    }\r\n\r\n    error_page   500 502 503 504  \/50x.html;\r\n    location = \/50x.html {\r\n        root   html;\r\n    }\r\n\r\n    location ~ \/purge(\/.*) {\r\n        allow                   127.0.0.1;\r\n        deny                    all;\r\n        proxy_cache_purge       czone \"$scheme:\/\/$host$1$is_args$args\";\r\n    }\r\n}\r\n<\/code><\/pre>\n<h2>\u8bbe\u7f6eApache \/ nginx\u7684\u542f\u52a8<\/h2>\n<pre class=\"post-pre\"><code>\uff0aApache\u304c\u8d77\u52d5\u4e2d\u306a\u3089\r\nsudo systemctl stop httpd.service\r\nsudo systemctl disable httpd.service\r\n\r\nsudo systemctl enable nginx.service\r\nsudo systemctl restart nginx.service\r\n<\/code><\/pre>\n<p>\u5982\u679c\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\u672c\u5730\u4e3b\u673a\uff0c\u5e94\u8be5\u53ef\u4ee5\u8fd0\u884c\u4f4d\u4e8e\/var\/www\/html\u7684index.php\u3002<\/p>\n<p>\u6211\u4eec\u6765\u8bd5\u8bd5\u3002\u8c22\u8c22\u3002 . .)<\/p>\n<h1>\u8bf7\u53c2\u8003<\/h1>\n<h4>git -&gt; git<\/h4>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx-build<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">ngx_cache_purge<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">ngx_pagespeed<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">ngx_pagespeed document<\/ul>\n<h4>Nginx\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u9ad8\u6027\u80fdWeb\u670d\u52a1\u5668\u548c\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u3002<\/h4>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx\u4e8b\u524d\u6e96\u5099\u304b\u3089\u30b5\u30fc\u30d3\u30b9\u8d77\u52d5\u307e\u3067\u306e\u30e1\u30e2<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx \u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u8ffd\u52a0\u3057\u3066\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8 (apt-get \u304b\u3089 \u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306b\u5909\u66f4)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Nginx\u306e\u30b3\u30de\u30f3\u30c9\u306b\u3064\u3044\u3066(\u624b\u52d5ver)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u3055\u304f\u3089VPS\u306b\u6700\u65b0Nginx1.9\u7cfb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u8a71<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">NGINX systemd service file<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">nginx\u306e\u30b3\u30f3\u30d1\u30a4\u30eb\u30e1\u30e2<\/ul>\n<h4>PHP-FPM<\/h4>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">nginx \u3068 PHP-FPM \u306e\u4ed5\u7d44\u307f\u3092\u3061\u3083\u3093\u3068\u7406\u89e3\u3057\u306a\u304c\u3089 PHP \u306e\u5b9f\u884c\u74b0\u5883\u3092\u69cb\u7bc9\u3059\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">CentOS7 + Nginx + PHP-FPM \u3067PHP\u3092\u5b9f\u884c\u3059\u308b\u74b0\u5883\u3092\u6574\u3048\u308b<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u5df2\u7ecf\u5efa\u7acb\u4e86\u4e00\u4e2a\u5305\u542bApache2 + MariaDB + PHP7\u7684\u73af\u5883\uff0c\u60f3\u8981\u5c06nginx\u914d\u7f6e\u4e3a\u4e00\u4e2aWeb\u670d [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-32694","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528nginx-build\u5728LAMP\u73af\u5883\u4e2d\u6784\u5efanginx - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528nginx-build\u5728lamp\u73af\u5883\u4e2d\u6784\u5efanginx\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528nginx-build\u5728LAMP\u73af\u5883\u4e2d\u6784\u5efanginx\" \/>\n<meta property=\"og:description\" content=\"\u6211\u5df2\u7ecf\u5efa\u7acb\u4e86\u4e00\u4e2a\u5305\u542bApache2 + MariaDB + PHP7\u7684\u73af\u5883\uff0c\u60f3\u8981\u5c06nginx\u914d\u7f6e\u4e3a\u4e00\u4e2aWeb\u670d [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528nginx-build\u5728lamp\u73af\u5883\u4e2d\u6784\u5efanginx\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-28T23:07:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T14:13:21+00:00\" \/>\n<meta name=\"author\" content=\"\u6e05, \u5b87\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u5b87\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/\",\"name\":\"\u4f7f\u7528nginx-build\u5728LAMP\u73af\u5883\u4e2d\u6784\u5efanginx - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-02-28T23:07:11+00:00\",\"dateModified\":\"2024-04-29T14:13:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528nginx-build\u5728LAMP\u73af\u5883\u4e2d\u6784\u5efanginx\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\",\"name\":\"\u6e05, \u5b87\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u5b87\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528nginx-build\u5728LAMP\u73af\u5883\u4e2d\u6784\u5efanginx - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528nginx-build\u5728lamp\u73af\u5883\u4e2d\u6784\u5efanginx\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528nginx-build\u5728LAMP\u73af\u5883\u4e2d\u6784\u5efanginx","og_description":"\u6211\u5df2\u7ecf\u5efa\u7acb\u4e86\u4e00\u4e2a\u5305\u542bApache2 + MariaDB + PHP7\u7684\u73af\u5883\uff0c\u60f3\u8981\u5c06nginx\u914d\u7f6e\u4e3a\u4e00\u4e2aWeb\u670d [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528nginx-build\u5728lamp\u73af\u5883\u4e2d\u6784\u5efanginx\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-02-28T23:07:11+00:00","article_modified_time":"2024-04-29T14:13:21+00:00","author":"\u6e05, \u5b87","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u5b87","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/","name":"\u4f7f\u7528nginx-build\u5728LAMP\u73af\u5883\u4e2d\u6784\u5efanginx - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-02-28T23:07:11+00:00","dateModified":"2024-04-29T14:13:21+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528nginx-build\u5728LAMP\u73af\u5883\u4e2d\u6784\u5efanginx"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e","name":"\u6e05, \u5b87","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","caption":"\u6e05, \u5b87"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx-build%e5%9c%a8lamp%e7%8e%af%e5%a2%83%e4%b8%ad%e6%9e%84%e5%bb%banginx%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/32694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=32694"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/32694\/revisions"}],"predecessor-version":[{"id":87949,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/32694\/revisions\/87949"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=32694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=32694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=32694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}