MODE DIGITAL CREATIONS LTD RC1694456
MODE DIGITAL CREATIONS LTD RC1694456
How to Change PHP Version

How to Change PHP Version

In the world of web development where innovation never rests and technology constantly evolves, it is always a good idea to stay up to date with the latest tools you need for your site’s development – one such is your PHP version.

PHP plays a pivotal role in the crafting of any website. At ModeWebHost, we understand this that is why we always strive to stay ahead in the ever-changing environment. In this article, we will be giving you step-by-step guides on the various ways through which you can change your PHP version.

 

How to Change PHP Version

There are several ways through which you can change the PHP version of your web hosting platform. Your options range from the popular control panel (cPanel) settings, .htaccess file configuration, custom PHP.ini file, contacting your web hosting provider support, or even the more advanced command line interface. The one you choose and stick to will often depend on your skill level in web development and management.

How to Change PHP Version via cPanel

  1. Login to your cPanel
  2. Navigate to the Software section and click on the MultiPHP Manager
  3. If you have more than one site running on the cPanel, you will want to check the box for the site you wish to change its PHP
  4. Choose the PHP version that best suits your preference (the latest is always recommended), and click Apply to save.

How to Chang PHP Version via .htaccess Configuration

  1. Login to your hosting account and navigate to the control panel or file manager
  2. Backup your current .htaccess file by downloading a copy to your computer, or duplicating it within the file manager.
  3. Open the .htaccess file for editing. You can do this with our built-in file editor, or download the file, then edit locally.
  4. Insert the following lines of code at the beginning of your .htaccess file to specify the desired PHP version. Replace X.X with the version you want (e.g., 7.4):

AddHandler application/x-httpd-phpX_X .php

For example, the current PHP version as of writing this article is 8.2, thus you should have something like “AddHandler application/x-httpd-php8.2 .php”

For CGI hosting providers, you will need to use the code:

AddHandler cgi-phpX_X .php

Again, replacing the X_X with the right version.

  1. Save the changes to your .htaccess file. If you downloaded to edit locally, simply upload back to the root directory of with your FTP client or file manager.

The only downside to using this method is that you will want to be very careful not to be forcing PHP versions that has reached its End of Life. This might cause your site to experience issues.

How to Change PHP Version via Custom PHP.ini File

  1. In the root directory of your website, create a new file and name it php.ini.
  2. Open the file with a file editor, or with you web host’s installed file m
  3. Add PHP version directive, and customize other settings as need. Ideally, your file should have a code like this:

; For PHP 8.2

short_open_tag = On

allow_url_fopen = Off

memory_limit = 256M

  1. Save changes to the file. If you did the editing locally, you will want to proceed to uploading back to the root directory.
  2. Now verify if your changes have been effected by visiting the website, or creating a PHP info file (info.php) containing the code “<?php phpinfo(); ?>”  to verify the version.

At any rate, if you are unsure or encounter difficulties with updating your PHP version, you can always reach out to our support team for assistance.

At modewebhost, we offer affordable and reliable web hosting, web development and domain registration services with round the clock customer support to attend to your needs.

Share this :
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *