{"id":375,"date":"2019-03-17T12:19:15","date_gmt":"2019-03-17T19:19:15","guid":{"rendered":"http:\/\/35.243.195.209\/?p=375"},"modified":"2019-03-17T12:19:15","modified_gmt":"2019-03-17T19:19:15","slug":"update-php-for-wordpress-on-centos","status":"publish","type":"post","link":"https:\/\/nanzhou.cc\/index.php\/2019\/03\/17\/update-php-for-wordpress-on-centos\/","title":{"rendered":"Update PHP for WordPress on CentOS"},"content":{"rendered":"<h2>Summary<\/h2>\n<p>In this post, I will introduce how to update PHP for WordPress.<\/p>\n<h2>Conclusion<\/h2>\n<p>As usual, I present the following snippets first.<\/p>\n<pre><code class=\"language-bash \">sudo yum remove php-common mod_php php-cli\nsudo yum install epel-release\nsudo yum install http:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm\nsudo yum install yum-utils\nsudo yum-config-manager --enable remi-php72\nsudo yum install php php-mysql \u2013y\nsudo systemctl restart httpd\n<\/code><\/pre>\n<h2>Details<\/h2>\n<p>For faster speed and more secure, I want to update the PHP from the default version to the latest one. I did some research and finally, succeed in updating. It is necessary to record it for future maintenance.<\/p>\n<p>Before the update, please read the official guide from WordPress first and back up your site. Use <a href=\"https:\/\/wordpress.org\/plugins\/php-compatibility-checker\/\">this checker<\/a> to check the compatibilities of all your plugins.<\/p>\n<p>Now, we start updating.<\/p>\n<h3>1. Remove the Old PHP<\/h3>\n<pre><code class=\"language-bash \"># php --version\nPHP 5.4.16 (cli) (built: Mar  7 2018 13:34:47) \nCopyright (c) 1997-2013 The PHP Group\nZend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies\n<\/code><\/pre>\n<p>We hate slow and unsecure ones and want to remove them.<\/p>\n<pre><code class=\"language-bash \">sudo yum remove php-common mod_php php-cli\n<\/code><\/pre>\n<p>After which, we get<\/p>\n<pre><code class=\"language-bash \">#  php --version\nbash: \/bin\/php: No such file or directory\n<\/code><\/pre>\n<h3>2. Install a Newer PHP<\/h3>\n<p>Turn on EPEL repo on a CentOS sever.<\/p>\n<pre><code class=\"language-bash \">sudo yum install epel-release\n<\/code><\/pre>\n<p>Turn on remi repo too.<\/p>\n<pre><code class=\"language-bash \">sudo yum install http:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm\n<\/code><\/pre>\n<p>Enable remi repo, run:<\/p>\n<pre><code class=\"language-bash \">sudo yum-config-manager --enable remi-php72\n<\/code><\/pre>\n<p>Update softwares.<\/p>\n<pre><code class=\"language-bash \">sudo yum install php php-mysql \u2013y\n<\/code><\/pre>\n<p>It will find the php 7.2.<\/p>\n<pre><code class=\"language-bash \">==================================================================================\n Package           Arch         Version                    Repository        Size\n==================================================================================\nInstalling:\n php               x86_64       7.2.16-1.el7.remi          remi-php72       3.2 M\n php-mysqlnd       x86_64       7.2.16-1.el7.remi          remi-php72       233 k\nInstalling for dependencies:\n php-cli           x86_64       7.2.16-1.el7.remi          remi-php72       4.8 M\n php-common        x86_64       7.2.16-1.el7.remi          remi-php72       1.1 M\n php-json          x86_64       7.2.16-1.el7.remi          remi-php72        64 k\n php-pdo           x86_64       7.2.16-1.el7.remi          remi-php72       126 k\n<\/code><\/pre>\n<p>Now check the version of php again.<\/p>\n<pre><code class=\"language-bash \"># php --version\nPHP 7.2.16 (cli) (built: Mar  5 2019 13:10:50) ( NTS )\nCopyright (c) 1997-2018 The PHP Group\nZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies\n    with Zend OPcache v7.2.16, Copyright (c) 1999-2018, by Zend Technologies\n\n<\/code><\/pre>\n<h3>3. Restart Apache<\/h3>\n<p>Remember to restart Apache service.<\/p>\n<pre><code class=\"language-bash \">systemctl restart httpd\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Summary In this post, I will introduce how to update PHP for WordPress. Conclusion As usual, I present the following snippets first. sudo yum remove php-common mod_php php-cli sudo yum install epel-release sudo yum install http:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm sudo yum install yum-utils sudo yum-config-manager &#8211;enable remi-php72 sudo yum install php php-mysql \u2013y sudo systemctl restart httpd Details&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,22],"tags":[],"class_list":["post-375","post","type-post","status-publish","format-standard","hentry","category-linux","category-operation-systems"],"_links":{"self":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/375","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/comments?post=375"}],"version-history":[{"count":1,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/375\/revisions"}],"predecessor-version":[{"id":376,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/375\/revisions\/376"}],"wp:attachment":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/media?parent=375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/categories?post=375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/tags?post=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}