{"id":44278,"date":"2024-10-06T14:23:14","date_gmt":"2024-10-06T06:23:14","guid":{"rendered":"https:\/\/server.hk\/cnblog\/44278\/"},"modified":"2024-10-06T14:23:14","modified_gmt":"2024-10-06T06:23:14","slug":"centos-%e4%b8%ad%e5%ae%89%e8%a3%9d-php-%e5%85%b7%e9%ab%94%e6%ad%a5%e9%a9%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/44278\/","title":{"rendered":"CentOS \u4e2d\u5b89\u88dd PHP \u5177\u9ad4\u6b65\u9a5f"},"content":{"rendered":"<h1 id=\"centos-%e4%b8%ad%e5%ae%89%e8%a3%9d-php-%e5%85%b7%e9%ab%94%e6%ad%a5%e9%a9%9f-fLNftSbyFW\">CentOS \u4e2d\u5b89\u88dd PHP \u5177\u9ad4\u6b65\u9a5f<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cPHP \u662f\u4e00\u7a2e\u5ee3\u6cdb\u4f7f\u7528\u7684\u4f3a\u670d\u5668\u7aef\u8173\u672c\u8a9e\u8a00\uff0c\u7279\u5225\u9069\u5408\u65bc\u7db2\u9801\u958b\u767c\u3002\u5c0d\u65bc\u4f7f\u7528 CentOS \u4f5c\u70ba\u4f3a\u670d\u5668\u64cd\u4f5c\u7cfb\u7d71\u7684\u7528\u6236\u4f86\u8aaa\uff0c\u5b89\u88dd PHP \u662f\u4e00\u500b\u91cd\u8981\u7684\u6b65\u9a5f\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5728 CentOS \u4e2d\u5b89\u88dd PHP \u7684\u5177\u9ad4\u6b65\u9a5f\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-fLNftSbyFW\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u5b89\u88dd PHP \u4e4b\u524d\uff0c\u78ba\u4fdd\u4f60\u7684 CentOS \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u66f4\u65b0\u7cfb\u7d71\uff1a<\/p>\n<pre><code>sudo yum update<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u78ba\u4fdd\u4f60\u5df2\u7d93\u5b89\u88dd\u4e86 EPEL\uff08Extra Packages for Enterprise Linux\uff09\u5eab\uff0c\u56e0\u70ba\u67d0\u4e9b PHP \u64f4\u5c55\u53ef\u80fd\u9700\u8981\u5f9e\u9019\u88e1\u7372\u53d6\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd EPEL\uff1a<\/p>\n<pre><code>sudo yum install epel-release<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-php-fLNftSbyFW\">\u5b89\u88dd PHP<\/h2>\n<p>\u5728 CentOS \u4e2d\u5b89\u88dd PHP \u53ef\u4ee5\u901a\u904e YUM \u5305\u7ba1\u7406\u5668\u4f86\u5b8c\u6210\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd PHP \u7684\u5177\u9ad4\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e5%ae%89%e8%a3%9d-php-fLNftSbyFW\">1. \u5b89\u88dd PHP<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd PHP \u7684\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<pre><code>sudo yum install php<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u9700\u8981\u5b89\u88dd\u7279\u5b9a\u7248\u672c\u7684 PHP\uff0c\u4f8b\u5982 PHP 7.4\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum install php74<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9d-php-%e6%93%b4%e5%b1%95-fLNftSbyFW\">2. \u5b89\u88dd PHP \u64f4\u5c55<\/h3>\n<p>\u6839\u64da\u4f60\u7684\u9700\u6c42\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5b89\u88dd\u4e00\u4e9b PHP \u64f4\u5c55\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 PHP \u64f4\u5c55\u53ca\u5176\u5b89\u88dd\u547d\u4ee4\uff1a<\/p>\n<ul>\n<li><code>sudo yum install php-mysqlnd<\/code> &#8211; \u7528\u65bc MySQL \u6578\u64da\u5eab\u7684\u652f\u6301<\/li>\n<li><code>sudo yum install php-gd<\/code> &#8211; \u7528\u65bc\u5716\u50cf\u8655\u7406\u7684\u652f\u6301<\/li>\n<li><code>sudo yum install php-xml<\/code> &#8211; \u7528\u65bc XML \u8655\u7406\u7684\u652f\u6301<\/li>\n<li><code>sudo yum install php-mbstring<\/code> &#8211; \u7528\u65bc\u591a\u5b57\u7bc0\u5b57\u7b26\u4e32\u8655\u7406\u7684\u652f\u6301<\/li>\n<\/ul>\n<h3 id=\"3-%e9%a9%97%e8%ad%89%e5%ae%89%e8%a3%9d-fLNftSbyFW\">3. \u9a57\u8b49\u5b89\u88dd<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5 PHP \u662f\u5426\u6b63\u78ba\u5b89\u88dd\uff1a<\/p>\n<pre><code>php -v<\/code><\/pre>\n<p>\u9019\u5c07\u986f\u793a PHP \u7684\u7248\u672c\u4fe1\u606f\uff0c\u78ba\u8a8d\u5b89\u88dd\u6210\u529f\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%ae-php-fLNftSbyFW\">\u914d\u7f6e PHP<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u5c0d PHP \u9032\u884c\u4e00\u4e9b\u57fa\u672c\u914d\u7f6e\u3002PHP \u7684\u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u4f4d\u65bc <code>\/etc\/php.ini<\/code>\u3002\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u7de8\u8f2f\u5668\uff08\u5982 vi \u6216 nano\uff09\u4f86\u7de8\u8f2f\u6b64\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/php.ini<\/code><\/pre>\n<p>\u5728\u9019\u88e1\uff0c\u4f60\u53ef\u4ee5\u6839\u64da\u9700\u8981\u4fee\u6539\u4e00\u4e9b\u8a2d\u7f6e\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u4fee\u6539 <code>memory_limit<\/code> \u4ee5\u589e\u52a0 PHP \u8173\u672c\u7684\u5167\u5b58\u9650\u5236\u3002<\/li>\n<li>\u4fee\u6539 <code>upload_max_filesize<\/code> \u4ee5\u589e\u52a0\u4e0a\u50b3\u6587\u4ef6\u7684\u5927\u5c0f\u9650\u5236\u3002<\/li>\n<\/ul>\n<h2 id=\"%e9%87%8d%e5%95%9f-web-%e4%bc%ba%e6%9c%8d%e5%99%a8-fLNftSbyFW\">\u91cd\u555f Web \u4f3a\u670d\u5668<\/h2>\n<p>\u5728\u5b8c\u6210 PHP \u7684\u5b89\u88dd\u548c\u914d\u7f6e\u5f8c\uff0c\u8a18\u5f97\u91cd\u555f\u4f60\u7684 Web \u4f3a\u670d\u5668\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f Apache\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u91cd\u555f\uff1a<\/p>\n<pre><code>sudo systemctl restart httpd<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f Nginx\uff0c\u5247\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-fLNftSbyFW\">\u7e3d\u7d50<\/h2>\n<p>\u5728 CentOS \u4e2d\u5b89\u88dd PHP \u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\uff0c\u901a\u904e\u4e0a\u8ff0\u6b65\u9a5f\uff0c\u4f60\u53ef\u4ee5\u8f15\u9b06\u5730\u5728\u4f60\u7684\u4f3a\u670d\u5668\u4e0a\u8a2d\u7f6e PHP \u74b0\u5883\u3002\u7121\u8ad6\u662f\u958b\u767c\u7db2\u7ad9\u9084\u662f\u904b\u884c\u61c9\u7528\u7a0b\u5e8f\uff0cPHP \u90fd\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u3002\u5982\u679c\u4f60\u9700\u8981\u66f4\u9ad8\u6548\u7684\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u670d\u52d9\uff0c\u9019\u5c07\u70ba\u4f60\u7684\u9805\u76ee\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5728 CentOS \u4e2d\u5b89\u88dd PHP \u7684\u5177\u9ad4\u6b65\u9a5f\uff0c\u5f9e\u74b0\u5883\u6e96\u5099\u5230\u914d\u7f6e\uff0c\u8f15\u9b06\u642d\u5efa PHP \u958b\u767c\u74b0\u5883\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-44278","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=44278"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44278\/revisions"}],"predecessor-version":[{"id":44279,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44278\/revisions\/44279"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=44278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=44278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=44278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}