Skip to main content
Magento

How to Change Magento PHP Version

Learn how to change PHP version for your Magento store safely. Ensure compatibility and maintain performance.

How to Change Magento PHP Version

Why Change PHP Version?

Updating to a newer PHP version improves security, performance, and adds support for modern features. However, compatibility is important.

Magento PHP Version Requirements

  • Magento 2.4.x: PHP 7.4, 8.0, 8.1
  • Magento 2.3.x: PHP 7.1, 7.2, 7.3, 7.4
  • Older versions require older PHP versions

Steps to Change PHP Version

Step 1: Check Current PHP Version

Log in to your server and run:

Code implementation available in the full documentation.

Step 2: Check Magento Compatibility

Ensure your Magento version supports the target PHP version. Refer to Magento documentation.

Step 3: Check Extension Compatibility

Verify all installed extensions are compatible with the new PHP version.

Step 4: Test on Staging

Always test the PHP version change on a staging environment first.

Step 5: Change PHP Version

Depending on your hosting provider:

  • cPanel: Select new version in MultiPHP Manager
  • Plesk: Change PHP version in PHP Settings
  • Command line: Update php.ini or htaccess

Step 6: Clear Cache

After changing PHP version, clear Magento cache:

Code implementation available in the full documentation.

Step 7: Test Your Store

Verify everything works correctly after the change.

Common PHP Version Issues

  • Deprecated functions in new PHP versions
  • Extension compatibility issues
  • Performance changes
  • Database connection issues

Troubleshooting

If you encounter errors after changing PHP version:

  • Check error logs in var/log/
  • Review extension compatibility
  • Verify database configuration
  • Check memory limits
  • Recompile Magento: bin/magento setup:di:compile

Best Practices

  • Always test on staging first
  • Create a full backup before changing
  • Have a rollback plan
  • Update extensions before upgrading PHP
  • Monitor performance metrics
  • Schedule during low-traffic hours

Conclusion

Changing PHP version requires careful planning and testing. Follow these steps to ensure a smooth transition that improves security and performance without breaking your store.

Need help with this?

Get managed Magento hosting tuned for performance.

Learn more