{"id":10778,"date":"2024-12-09T07:06:57","date_gmt":"2024-12-09T07:06:57","guid":{"rendered":"https:\/\/blog.trustedhosting.in\/?p=10778"},"modified":"2024-12-09T07:07:35","modified_gmt":"2024-12-09T07:07:35","slug":"how-to-changing-your-installed-php-version","status":"publish","type":"post","link":"https:\/\/www.webystrata.com\/blog\/how-to-changing-your-installed-php-version\/","title":{"rendered":"How to Changing your installed PHP version"},"content":{"rendered":"<h1><a href=\"https:\/\/www.trustedhosting.in\/cpanel-hosting.html\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-10777 size-full\" title=\"How to Changing your installed PHP version\" src=\"https:\/\/blog.trustedhosting.in\/wp-content\/uploads\/2024\/12\/12304102_4954857.jpg\" alt=\"How to Changing your installed PHP version\" width=\"2000\" height=\"2000\" srcset=\"https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/12304102_4954857.jpg 2000w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/12304102_4954857-300x300.jpg 300w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/12304102_4954857-1024x1024.jpg 1024w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/12304102_4954857-150x150.jpg 150w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/12304102_4954857-768x768.jpg 768w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/12304102_4954857-1536x1536.jpg 1536w\" sizes=\"auto, (max-width: 2000px) 100vw, 2000px\" \/><\/a><\/h1>\n<h1>How to Changing your installed PHP version<\/h1>\n<p>When looking at your web stack, you may notice you are running on a version of PHP which is behind the latest one. Often, we might assume the best course of action would be to update to the latest version. For most software, that is true, however PHP versions are a little different. It can still be a good idea to update, but there are several things to consider before you do.<\/p>\n<section id=\"considerations-before-you-upgrade\">\n<h2>Considerations before you upgrade<\/h2>\n<p>PHP is still being actively developed, and the developers have chosen not to maintain backwards compatibility. This means as the language changes, features which are no longer considered good practice, or have been superseded by faster or more secure versions are \u201cdeprecated\u201d. That means they are marked as deprecated, and eventually removed from the language entirely. If your application uses one of these deprecated features, it will stop working if you update PHP versions without also updating your application!<\/p>\n<p>PHP.net provide a comprehensive list of these deprecated functions between each released version:<\/p>\n<ul class=\"simple\">\n<li>5.5 &gt; 5.6<\/li>\n<li>5.6 &gt; 7.0<\/li>\n<li>7.0 &gt; 7.1<\/li>\n<li>7.1 &gt; 7.2<\/li>\n<\/ul>\n<p>As you can see, there\u2019s a fair amount there which may cause your application to break under a new version of PHP. Due to this, we always recommend testing your application under the PHP version of choice before<\/p>\n<p>Another thing to consider are your installed PHP modules. You\u2019ll want to check that you can have the same modules under the new interpreter version.<\/p>\n<\/section>\n<section id=\"how-to-upgrade-on-your-system\">\n<h2>How to upgrade on your system<\/h2>\n<p>Making the change to a different PHP interpreter version varies in difficulty depending on what type of server you have. Some are as easy as selecting a dropdown, while some require manually configuring the new version<\/p>\n<section id=\"plesk-12\">\n<h3>Plesk 12+<\/h3>\n<p>From version 12 onwards, Plesk has support for multiple PHP versions built in. Installing different versions is done via the Updates &amp; Upgrades section, and changing between them is done by a dropdown menu in Plesk. This allows you to switch PHP versions quickly and easily. For more information please do take a look at\u00a0the official Plesk guide.<\/p>\n<\/section>\n<section id=\"whm-cpanel\">\n<h3>WHM\/cPanel<\/h3>\n<p>WHM\/<a href=\"https:\/\/www.trustedhosting.in\/cpanel-hosting.html\" target=\"_blank\" rel=\"noopener\">cPanel<\/a> also supports multiple versions of PHP, if you are running EasyApache 4. PHP interpreter versions can be installed via EasyApache 4 and managed in WHM under\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">Home<\/span>\u00a0<span class=\"pre\">&gt;&gt;<\/span>\u00a0<span class=\"pre\">Software<\/span>\u00a0<span class=\"pre\">&gt;&gt;<\/span>\u00a0<span class=\"pre\">MultiPHP<\/span>\u00a0<span class=\"pre\">Manager<\/span><\/code>.<\/p>\n<p>For more information please do take a look at\u00a0the official <a href=\"https:\/\/www.trustedhosting.in\/cpanel-hosting.html\" target=\"_blank\" rel=\"noopener\">cPanel<\/a> guide.<\/p>\n<\/section>\n<section id=\"ukfast-magento-managed-platform\">\n<h3>UKFast Magento managed platform<\/h3>\n<p>If you have one of our Magento managed platforms, our support team will assist in changing the PHP version to what you require. Please just let us know by raising a support request and our engineers will arrange a time to make the change. Please do note that while we will make the change to the PHP version, your should still be testing your application beforehand to make sure your application will run on the requested PHP version.<\/p>\n<\/section>\n<section id=\"standard-apache-or-nginx-server\">\n<h3>Standard Apache or NGINX server<\/h3>\n<p>If you expect to be changing PHP versions over the lifetime of your application we highly recommend a multi PHP environment. It is possible to do so without a control panel, but it is an involved process which requires downtime and carries risks.<\/p>\n<div class=\"admonition warning\">\n<p>This is an advanced process and you should only attempt this if you are very comfortable with setting up web stacks by hand. All code given here is for example only, please do not copy paste it directly as the process will vary depending on how your server is set up. The basic steps are the same but the commands will change in different setups.<\/p>\n<\/div>\n<p>The example here assumes you are using a CentOS 7 server and running PHP-FPM. If you run any other OS or do not use PHP-FPM, please adjust this to be suitable to your environment.<\/p>\n<section id=\"backups\">\n<h4>Backups<\/h4>\n<p>The first step is to ensure you have backups in place so should there be any issues you have a fallback. You can also take a copy of all your existing PHP configuration which may let you roll back<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre>mkdir \/root\/php_upgrade_backup\/\r\nphp -v &gt; \/root\/php_upgrade_backup\/version\r\nphp -m &gt; \/root\/php_upgrade_backup\/modules\r\nphp -i &gt; \/root\/php_upgrade_backup\/info\r\nrpm -qa <span class=\"p\">|<\/span> grep -i php &gt; \/root\/php_upgrade_backup\/rpms\r\ncp -r \/etc\/php.d\/ \/root\/php_upgrade_backup\/\r\ncp -r \/etc\/php-fpm.conf \/root\/php_upgrade_backup\/\r\ncp -r \/etc\/php-fpm.d\/ \/root\/php_upgrade_backup\/\r\ncp \/etc\/php.ini \/root\/php_upgrade_backup\/\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/section>\n<section id=\"remove-the-current-php-version-and-reinstall\">\n<h4>Remove the current PHP version and reinstall<\/h4>\n<p>We\u2019re working on a CentOS 7 server and we are going to install PHP 7.1 from the Remi repository. So first we\u2019ll install Remi (if it\u2019s not already present):<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre>wget http:\/\/rpms.remirepo.net\/enterprise\/remi-release-7.rpm <span class=\"o\">&amp;&amp;<\/span> rpm -Uvh remi-release-7.rpm <span class=\"o\">&amp;&amp;<\/span> rm -f remi-release-7.rpm\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<p>Now we need to remove all the existing PHP packages from the server:<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre>yum remove <span class=\"s1\">'*php*'<\/span>\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<p>And install the version we want, with all the modules needed:<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre>yum install --enablerepo<span class=\"o\">=<\/span>remi-php71,remi,epel php php-pdo php-mysqlnd php-opcache php-xml php-mcrypt php-gd php-devel php-mysql php-intl php-mbstring php-bcmath php-json php-iconv php-pecl-redis php-fpm php-zip php-soap\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/section>\n<section id=\"reinstate-old-settings\">\n<h4>Reinstate old settings<\/h4>\n<p>Now we\u2019ve removed and reinstalled a new version, we need to copy our previous settings into the new PHP version. We can use the backup we took earlier (<code class=\"docutils literal notranslate\"><span class=\"pre\">\/root\/php_upgrade_backup\/php.ini<\/span><\/code>) to see all our previous values and copy those to the new\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">php.ini<\/span><\/code>\u00a0using the editor of your choice:<\/p>\n<p>If we have custom pools set up in PHP-FPM, then we probably want to stop the default pool running, which we can do by blanking the default\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">www.conf<\/span><\/code>\u00a0file:<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre><span class=\"nb\">echo<\/span> <span class=\"s2\">\";Default file, please don't remove\"<\/span> &gt; \/etc\/php-fpm.d\/www.conf\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/section>\n<section id=\"config-test-and-start\">\n<h4>Config test and start<\/h4>\n<p>Now that\u2019s set up, we can test the configuration, and start the PHP-FPM service.<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre>php-fpm -t\r\nservice php-fpm start\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<p>And ensure that PHP-FPM will start on a system reboot:<\/p>\n<div class=\"highlight-bash notranslate\">\n<div class=\"highlight\">\n<blockquote>\n<pre>systemctl <span class=\"nb\">enable<\/span> php-fpm\r\n<\/pre>\n<\/blockquote>\n<\/div>\n<\/div>\n<p>You should then have your application running under the new version of PHP.<\/p>\n<\/section>\n<\/section>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>How to Changing your installed PHP version When looking at your web stack, you may notice you are running on&hellip;<\/p>\n","protected":false},"author":1,"featured_media":10777,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10778","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-latest-updates"],"_links":{"self":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts\/10778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/comments?post=10778"}],"version-history":[{"count":1,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts\/10778\/revisions"}],"predecessor-version":[{"id":10779,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts\/10778\/revisions\/10779"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/media\/10777"}],"wp:attachment":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/media?parent=10778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/categories?post=10778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/tags?post=10778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}