{"id":75,"date":"2022-03-31T10:59:47","date_gmt":"2022-03-31T02:59:47","guid":{"rendered":"http:\/\/blog.ohmmx.com\/?p=75"},"modified":"2022-03-31T14:06:05","modified_gmt":"2022-03-31T06:06:05","slug":"nginx%e6%95%b4%e5%90%88php","status":"publish","type":"post","link":"http:\/\/blog.ohmmx.com\/?p=75","title":{"rendered":"Nginx\u6574\u5408PHP"},"content":{"rendered":"\n<p class=\"has-large-font-size\">\u5b89\u88c5PHP<\/p>\n\n\n\n<p>\u4ece\u7f51\u7ad9 http:\/\/rpms.remirepo.net\/enterprise\/ \u627e\u5230\u7cfb\u7edf\u5bf9\u5e94\u7684rpm<\/p>\n\n\n\n<p>\u73b0\u5728\u662fCentOS8\uff0c\u8fd9\u91cc\u4f7f\u7528 http:\/\/rpms.remirepo.net\/enterprise\/remi-release-8.rpm<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf -y install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-8.rpm<\/code><\/pre>\n\n\n\n<p>\u67e5\u770b\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum repolist<\/code><\/pre>\n\n\n\n<p>\u663e\u793a\u6709 remi-modular \u548c remi-safe \u5c31\u8868\u793a\u5b89\u88c5\u6210\u529f\u4e86\uff01<\/p>\n\n\n\n<p>\u67e5\u770b\u53ef\u4ee5\u5b89\u88c5\u7684\u7248\u672c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf module list php<\/code><\/pre>\n\n\n\n<p>\u627e\u5230\u9700\u8981\u5b89\u88c5\u7684\u7248\u672c\uff0c\u5e76\u8bb0\u4e0bStream\u5217\u5bf9\u5e94\u7684\u540d\u79f0\uff0c\u6bd4\u59828.0\u7248\u672c\u5c31\u6709\u4e24\u4e2a\u9009\u62e9 8.0 \u548c remi-8.0<\/p>\n\n\n\n<p>\u8bbe\u5b9aPHP\u7248\u672c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf module reset php\nsudo dnf module enable php:remi-8.1<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5PHP<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf -y install php\nsudo dnf -y install php php-gd php-mysqlnd<\/code><\/pre>\n\n\n\n<p>\u5176\u4e2d\u540e\u9762\u51e0\u4e2a\u6a21\u5757\u662fWordPress\u6240\u9700\u8981\u7684\uff0c\u53ef\u4ee5\u914c\u60c5\u5b89\u88c5\u3002<\/p>\n\n\n\n<p>\u914d\u7f6ephp-fpm\uff0c\u914d\u7f6e\u6587\u4ef6 \/etc\/php-fpm.d\/www.conf\uff0c\u8c03\u6574\u5982\u4e0b\u884c\u7684\u8bbe\u7f6e\uff0c\u4e0enginx\u542f\u52a8\u7528\u6237\u4e00\u81f4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>user = username\ngroup = group<\/code><\/pre>\n\n\n\n<p>\u542f\u52a8php-fpm<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable --now php-fpm<\/code><\/pre>\n\n\n\n<p class=\"has-large-font-size\">\u914d\u7f6eNginx<\/p>\n\n\n\n<p>\u4ee5 WordPress \u4e3a\u4f8b<\/p>\n\n\n\n<p>\u8bbe\u7f6enginx\u542f\u52a8\u7528\u6237\u548c\u7ec4\uff0c\u914d\u7f6e\u6587\u4ef6 \/etc\/nginx\/nginx.conf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># user nginx; \u8fd9\u4e2a\u662f\u9ed8\u8ba4\u7528\u6237\uff0c\u5982\u679c\u8fd9\u91cc\u4e0d\u8c03\u6574php-fpm\u7684\u914d\u7f6e\u5c31\u8981\u8bbe\u7f6e\u6210nginx\nuser username group;<\/code><\/pre>\n\n\n\n<p>\u5728nginx\u7684\u914d\u7f6e\u76ee\u5f55\u4e0b \/etc\/nginx\/conf.d\/ \u65b0\u5efa\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6 wordpress.conf<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n        listen      2000;\n        server_name wordpress.site.com;\n\n        location \/ {\n                root   \/home\/wordpress;\n                index  index.php index.html index.htm;\n                autoindex off;\n                autoindex_exact_size off;\n                autoindex_localtime on;\n        }\n\n        location ~ \\.php$ {\n                try_files      $uri = 404;\n                root           \/home\/wordpress;\n                fastcgi_pass   127.0.0.1:9000;\n                fastcgi_index  index.php;\n                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;\n                fastcgi_param  SCRIPT_NAME      $fastcgi_script_name;\n                include        fastcgi_params;\n        }\n}<\/code><\/pre>\n\n\n\n<p>WordPress\u91cc\u7684\u6587\u4ef6\u4e5f\u8981\u8bbe\u7f6e\u4e3a\u540c\u6837\u7684\u7528\u6237\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chown -R username:group \/home\/wordpress<\/code><\/pre>\n\n\n\n<p class=\"has-large-font-size\">\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898<\/p>\n\n\n\n<p>Nginx \u548c php-fpm \u4e00\u5b9a\u8981\u8bbe\u7f6e\u76f8\u540c\u7684\u7528\u6237\u540d\u548c\u7ec4\uff0c\u4e0d\u7136\u4f1a\u6587\u4ef6\u6743\u9650\u4e0d\u8db3\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u8fd9\u4e2a\u95ee\u9898\u7684\u539f\u56e0\u662f\u8def\u5f84\u4e0a\u7684\u76ee\u5f55\u6ca1\u6709\u8bbf\u95ee\u6743\u9650<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>open() \"\/var\/lib\/nginx\/tmp\/fastcgi\/2\/00\/0000000002\" failed (13: Permission denied)<\/code><\/pre>\n\n\n\n<p>\u628a fastcgi \u76ee\u5f55\u7684\u6743\u9650\u8bbe\u7f6e\u4e3a755\u5c31\u597d\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5PHP \u4ece\u7f51\u7ad9 http:\/\/rpms.remirepo.net\/enter &hellip; <a href=\"http:\/\/blog.ohmmx.com\/?p=75\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[15,23],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-server","tag-nginx","tag-php"],"_links":{"self":[{"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=75"}],"version-history":[{"count":8,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":177,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=\/wp\/v2\/posts\/75\/revisions\/177"}],"wp:attachment":[{"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ohmmx.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}