{"id":43500,"date":"2024-10-05T19:42:47","date_gmt":"2024-10-05T11:42:47","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43500\/"},"modified":"2024-10-05T19:42:47","modified_gmt":"2024-10-05T11:42:47","slug":"centos-%e5%8d%87%e7%b4%9a%e7%8f%be%e6%9c%89-php-%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43500\/","title":{"rendered":"CentOS \u5347\u7d1a\u73fe\u6709 PHP \u7248\u672c"},"content":{"rendered":"<h1 id=\"centos-%e5%8d%87%e7%b4%9a%e7%8f%be%e6%9c%89-php-%e7%89%88%e6%9c%ac-ZvhrveWBQJ\">CentOS \u5347\u7d1a\u73fe\u6709 PHP \u7248\u672c<\/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\u662f\u5728\u958b\u767c\u52d5\u614b\u7db2\u7ad9\u548c\u7db2\u7d61\u61c9\u7528\u7a0b\u5e8f\u6642\u3002\u96a8\u8457 PHP \u7684\u4e0d\u65b7\u66f4\u65b0\uff0c\u5347\u7d1a\u5230\u6700\u65b0\u7248\u672c\u4e0d\u50c5\u80fd\u63d0\u9ad8\u6027\u80fd\uff0c\u9084\u80fd\u589e\u5f37\u5b89\u5168\u6027\u548c\u529f\u80fd\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS \u7cfb\u7d71\u4e0a\u5347\u7d1a\u73fe\u6709\u7684 PHP \u7248\u672c\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e8%a6%81%e5%8d%87%e7%b4%9a-php-%e7%89%88%e6%9c%ac%ef%bc%9f-ZvhrveWBQJ\">\u70ba\u4ec0\u9ebc\u8981\u5347\u7d1a PHP \u7248\u672c\uff1f<\/h2>\n<p>\u5347\u7d1a PHP \u7248\u672c\u7684\u539f\u56e0\u4e3b\u8981\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>\u5b89\u5168\u6027\uff1a<\/strong>\u820a\u7248\u672c\u7684 PHP \u53ef\u80fd\u5b58\u5728\u5df2\u77e5\u7684\u5b89\u5168\u6f0f\u6d1e\uff0c\u5347\u7d1a\u53ef\u4ee5\u6e1b\u5c11\u88ab\u653b\u64ca\u7684\u98a8\u96aa\u3002<\/li>\n<li><strong>\u6027\u80fd\uff1a<\/strong>\u65b0\u7248\u672c\u901a\u5e38\u6703\u5c0d\u6027\u80fd\u9032\u884c\u512a\u5316\uff0c\u80fd\u5920\u66f4\u5feb\u5730\u8655\u7406\u8acb\u6c42\u3002<\/li>\n<li><strong>\u65b0\u529f\u80fd\uff1a<\/strong>\u65b0\u7248\u672c\u6703\u5f15\u5165\u65b0\u7684\u529f\u80fd\u548c\u6539\u9032\uff0c\u5e6b\u52a9\u958b\u767c\u8005\u66f4\u9ad8\u6548\u5730\u7de8\u5beb\u4ee3\u78bc\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%aa%a2%e6%9f%a5%e7%95%b6%e5%89%8d-php-%e7%89%88%e6%9c%ac-ZvhrveWBQJ\">\u6aa2\u67e5\u7576\u524d PHP \u7248\u672c<\/h2>\n<p>\u5728\u5347\u7d1a\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u6aa2\u67e5\u7576\u524d\u5b89\u88dd\u7684 PHP \u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>php -v<\/code><\/pre>\n<p>\u9019\u5c07\u986f\u793a\u7576\u524d\u7684 PHP \u7248\u672c\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e5%8d%87%e7%b4%9a-php-%e7%9a%84%e6%ad%a5%e9%a9%9f-ZvhrveWBQJ\">\u5347\u7d1a PHP \u7684\u6b65\u9a5f<\/h2>\n<h3 id=\"1-%e6%9b%b4%e6%96%b0%e7%b3%bb%e7%b5%b1-ZvhrveWBQJ\">1. \u66f4\u65b0\u7cfb\u7d71<\/h3>\n<p>\u5728\u9032\u884c\u4efb\u4f55\u5347\u7d1a\u4e4b\u524d\uff0c\u5efa\u8b70\u5148\u66f4\u65b0\u7cfb\u7d71\u7684\u5305\u7ba1\u7406\u5668\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum update<\/code><\/pre>\n<h3 id=\"2-%e5%ae%89%e8%a3%9d-epel-%e5%92%8c-remi-repository-ZvhrveWBQJ\">2. \u5b89\u88dd EPEL \u548c Remi Repository<\/h3>\n<p>\u70ba\u4e86\u7372\u5f97\u6700\u65b0\u7684 PHP \u7248\u672c\uff0c\u60a8\u9700\u8981\u5b89\u88dd EPEL \u548c Remi Repository\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u5b89\u88dd\uff1a<\/p>\n<pre><code>sudo yum install epel-release\nsudo yum install https:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm<\/code><\/pre>\n<h3 id=\"3-%e5%95%9f%e7%94%a8-remi-repository-ZvhrveWBQJ\">3. \u555f\u7528 Remi Repository<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u555f\u7528 Remi Repository\uff0c\u9019\u6a23\u60a8\u5c31\u53ef\u4ee5\u5b89\u88dd\u6700\u65b0\u7248\u672c\u7684 PHP\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum-config-manager --enable remi-php80<\/code><\/pre>\n<p>\u9019\u88e1\u7684 &#8220;80&#8221; \u8868\u793a PHP 8.0\uff0c\u60a8\u53ef\u4ee5\u6839\u64da\u9700\u8981\u9078\u64c7\u5176\u4ed6\u7248\u672c\u3002<\/p>\n<h3 id=\"4-%e5%ae%89%e8%a3%9d-php-ZvhrveWBQJ\">4. \u5b89\u88dd PHP<\/h3>\n<p>\u73fe\u5728\u53ef\u4ee5\u5b89\u88dd\u6700\u65b0\u7248\u672c\u7684 PHP \u4e86\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum install php<\/code><\/pre>\n<p>\u5982\u679c\u60a8\u9700\u8981\u5b89\u88dd\u7279\u5b9a\u7684 PHP \u64f4\u5c55\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo yum install php-{extension_name}<\/code><\/pre>\n<p>\u4f8b\u5982\uff0c\u5b89\u88dd MySQL \u64f4\u5c55\uff1a<\/p>\n<pre><code>sudo yum install php-mysqlnd<\/code><\/pre>\n<h3 id=\"5-%e9%87%8d%e5%95%9f-web-%e4%bc%ba%e6%9c%8d%e5%99%a8-ZvhrveWBQJ\">5. \u91cd\u555f Web \u4f3a\u670d\u5668<\/h3>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u91cd\u555f Web \u4f3a\u670d\u5668\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002\u5c0d\u65bc Apache \u4f3a\u670d\u5668\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo systemctl restart httpd<\/code><\/pre>\n<p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f Nginx\uff0c\u5247\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<pre><code>sudo systemctl restart nginx<\/code><\/pre>\n<h3 id=\"6-%e9%a9%97%e8%ad%89-php-%e7%89%88%e6%9c%ac-ZvhrveWBQJ\">6. \u9a57\u8b49 PHP \u7248\u672c<\/h3>\n<p>\u6700\u5f8c\uff0c\u60a8\u53ef\u4ee5\u518d\u6b21\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5 PHP \u7248\u672c\uff0c\u78ba\u4fdd\u5347\u7d1a\u6210\u529f\uff1a<\/p>\n<pre><code>php -v<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-ZvhrveWBQJ\">\u7e3d\u7d50<\/h2>\n<p>\u5347\u7d1a CentOS \u4e0a\u7684 PHP \u7248\u672c\u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\uff0c\u901a\u904e\u9075\u5faa\u4e0a\u8ff0\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u78ba\u4fdd\u60a8\u7684\u4f3a\u670d\u5668\u904b\u884c\u6700\u65b0\u7684 PHP \u7248\u672c\uff0c\u5f9e\u800c\u63d0\u9ad8\u5b89\u5168\u6027\u548c\u6027\u80fd\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u9069\u5408\u4e0d\u540c\u9700\u6c42\u7684\u7528\u6236\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u9084\u662f\u5176\u4ed6\u5730\u5340\u7684\u670d\u52d9\uff0c\u6211\u5011\u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5728 CentOS \u4e0a\u5347\u7d1a\u73fe\u6709 PHP \u7248\u672c\uff0c\u78ba\u4fdd\u60a8\u7684\u4f3a\u670d\u5668\u904b\u884c\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u6027\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-43500","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43500","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=43500"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43500\/revisions"}],"predecessor-version":[{"id":43501,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43500\/revisions\/43501"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}