{"id":188,"date":"2021-04-15T17:34:46","date_gmt":"2021-04-15T09:34:46","guid":{"rendered":"https:\/\/explause.com\/?p=188"},"modified":"2021-04-15T19:19:32","modified_gmt":"2021-04-15T11:19:32","slug":"nginxphp8%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/devdoge.org\/?p=188","title":{"rendered":"nginx+php8\u914d\u7f6e"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">apache httpd\u592a\u5403\u5185\u5b58\uff0c\u4f7f\u7528php\u7684\u8bdd8G\u5185\u5b58\u5f88\u5feb\u90fd\u80fd\u5403\u5149\uff0c\u50cf\u6211\u8fd9\u6837\u7684\u7a77\u7ad9\u957f\u6302\u7f51\u7ad9\u90fd\u662f\u5728512M\u7684\u5783\u573eVPS\u4e0a\u7684\uff0c\u7528\u4e86httpd\u5c31\u4f1a\u7206\u5185\u5b58\uff0c\u5957\u4e0aCDN\u65f6\u4e0d\u65f6\u5c31\u4f1a525\uff0c\u8fd8\u662f\u6362\u6210nginx\u597d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u5b89\u88c5\u597dPHP\uff0c\u7f16\u8bd1\u5b89\u88c5\u8981\u6dfb\u52a0&#8211;enable-fpm\u9009\u9879\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">CentOS\u5b98\u65b9\u6e90\u7684PHP\u7248\u672c\u6bd4\u8f83\u8001\uff0c\u5b89\u88c5\u6700\u65b0\u7684Wordpress\u90fd\u4e0d\u884c\uff0c\u90a3\u5c31\u76f4\u63a5\u5e72\u5230\u6700\u65b0\u7248\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b89\u88c5\u597dPHP8\u4e4b\u540e\uff0c\u8fd8\u8981\u81ea\u5df1\u521b\u5efaphp-fpm\u670d\u52a1\uff0c\u56e0\u4e3anginx\u53ea\u662f\u4e00\u4e2a\u9759\u6001http\u670d\u52a1\u5668\uff0c\u6240\u4ee5php-fpm\u4e5f\u662f\u4e00\u4e2a\u670d\u52a1\u5668\u3002\u7cfb\u7edf\u9ed8\u8ba4\u4f7f\u7528systemd\u7ba1\u7406\u670d\u52a1\uff0c\u7528\u5b83\u521b\u5efa\u4e00\u4e2a\u670d\u52a1\u5f88\u7b80\u5355\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u521b\u5efa\u4e00\u4e2aservice\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/usr\/lib\/systemd\/system\/php-fpm.service<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=PHP FPM Service\nRequires=nginx.service\nAfter=network-online.target\n\n&#91;Service]\nType=simple\nExecStart=\/usr\/local\/sbin\/php-fpm -c \/usr\/local\/lib\/php.ini\n\n&#91;Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u7684\u4ee3\u7801\u9ed8\u8ba4\u8981\u6c42nginx\u542f\u52a8\u540e\u542f\u52a8php-fpm\u3002\u5982\u679c\u4e0d\u5e0c\u671b\u8fd9\u6837\u5220\u9664<strong>Requires<\/strong>\u8fd9\u4e00\u884c\u5c31\u884c\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u521b\u5efaphp-fpm\u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/usr\/local\/etc\/php-fpm.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;www]\nuser = apache\ngroup = apache\nlisten = 127.0.0.1:9000\nlisten.allowed_clients = 127.0.0.1\npm = dynamic\npm.max_children = 5\npm.start_servers = 2\npm.min_spare_servers = 1\npm.max_spare_servers = 3\n\n&#91;global]\ndaemonize = no<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u8c03\u6574php-fpm\u670d\u52a1\u5668\u7684\u6570\u91cf\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>pm.max_children             \u610f\u601d\u662f\u6700\u5927\u521b\u5efa\u7684\u670d\u52a1\u5668\u6570\u91cf <\/li><li>pm.start_servers             \u610f\u601d\u662f\u521a\u542f\u52a8\u7684\u65f6\u5019\u521b\u5efa\u7684\u670d\u52a1\u5668\u6570\u91cf <\/li><li>pm.min_spare_servers   \u6700\u5c0f\u7a7a\u670d\u52a1\u5668\u6570\u91cf <\/li><li>pm.max_spare_servers  \u6700\u5927\u7a7a\u670d\u52a1\u5668\u6570\u91cf<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f00\u542fphp-fpm\u670d\u52a1\u5e76\u5f00\u673a\u542f\u52a8\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl start php-fpm\nsystemctl enable php-fpm<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u8fd8\u8981\u914d\u7f6enginx\u5c06php\u6587\u4ef6\u4ea4\u7ed9php-fpm\u5904\u7406\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/etc\/nginx\/nginx.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728server\u914d\u7f6e\u6846\u91cc\u9762\u6dfb\u52a0\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>location ~ &#91;^\/]\\.php(\/|$) {\n                fastcgi_param HTTP_PROXY \"\";\n                fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;\n                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n                fastcgi_pass 127.0.0.1:9000;\n                fastcgi_index index.php;\n                include fastcgi_params;\n       }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u6837\u5b89\u88c5\u4e86wordpress\u7684\u8bdd\u5c06wp\u7684\u6587\u4ef6\u590d\u5236\u5230nginx\u914d\u7f6e\u91ccroot\u53c2\u6570\u76ee\u5f55\u4e0b\u5c31\u80fd\u4f7f\u7528\u5566\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>LNMP or LEMP\uff0c\u5728\u4f4e\u5185\u5b58VPS\u4e0a\u4f7f\u7528php\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[24,17],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-opt","tag-nginx","tag-php8"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/devdoge.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":4,"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/devdoge.org\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/devdoge.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devdoge.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devdoge.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}