Skip to main content

How to Upgrade PHP from 5.x to 7.4

Updated over a week ago

PHP 5.2 is end-of-life (EOL) and extremely outdated. So direct upgrades are not supported (5.2 to 7.4). A backup is mandatory before proceeding and a dev or staging is recommended.

Prerequisites

  • Access to cPanel or

  • Access to the Funio Hub

  • SSH Access

Task completion: depends on expertise

Expertise: advanced

How to do it?

  1. Log in to your cPanel.

  2. In the Software section, choose Select PHP Version.

  3. Check your current PHP version and the PHP extensions you have selected.

  4. Check what your CMS is if you use one

  5. If you have a CMS, check what plugins and themes you are using

  6. Check the PHP requirements

Backup your Website

  • cPanel > File Manager

  • Compress and download:

    • your website root directory (default: public_html)

    • application folders

  • Backup database(s):

Audit Application Compatibility

Common incompatibilities

  • mysql_* functions (removed)

  • ereg_* functions (removed)

  • register_globals

  • magic_quotes

  • Old constructors (ClassName())

Recommended tools

  • PHPCompatibility (PHP_CodeSniffer)

  • CMS upgrade checkers

  • Test on a staging environment

Recommended Upgrade Path

PHP 5.2 > 5.6 > 7.0 > 7.4

This minimizes fatal errors and simplifies debugging.

PHP Extensions

Ensure the following PHP 7.4 extensions are enabled under Select PHP Version > Extensions

  • mysqli

  • pdo / pdo_mysql

  • curl

  • json

  • mbstring

  • gd

  • intl

  • opcache

Replace deprecated functions

PHP 5.2

PHP 7.4

mysql_*

mysqli / PDO

ereg_*

preg_*

split()

explode()

each()

foreach

Example

#php 5.2 
mysql_query($sql);

#php 7.4
mysqli_query($conn, $sql);

Troubleshooting and Common Issues

  1. Enable error logs

  2. Check for fatal errors in deprecated functions

  3. Databases connections errors

  4. Update CMS core

  5. Update plugins/modules

  6. Remove abandoned extensions

  7. Remove outdated and unsupported plugins and themes

Note: If something doesn’t work, you can temporarily switch back to your previous version. If you don’t have experience with this process, we recommend contacting your developer.

Did this answer your question?