Please note: This article explains how to manage PHP on our Web Hosting/Reseller Hosting servers. If you're running a VPS or Cloud Dedicated, these settings will not be relevant unless you've specifically ordered a CloudLinux license from our team and had them install it.
All Web Hosting and Reseller Hosting accounts at NameHero have the ability to fully customize PHP to meet specific requirements for each cPanel account.
By default all servers on our high-speed cloud use the latest stable version of PHP but you may need to make changes based on the applications/software you use for your website.
For optimal performance and security we always recommend using the latest version of PHP, but with our relationship with CloudLinux we are able to offer older versions of PHP that can be used securely.
To configure PHP for your website, go to cPanel -> Select PHP Version:
This dashboard allows full control over PHP version, PHP extensions, and modification of PHP limits:
Select PHP Version
The active version of PHP is shown here noted by (current). You may click the dropdown to select a different version.
At the time of writing this tutorial, PHP 7.3 is stable but we've also begun releasing PHP 7.4 across our network. Additionally, PHP 5.6 is very old and will be removed in coming months.
Once selected, you'll then need to click Set as current to deploy the change:
Once confirmed, your website will be running the version selected.
Please note: if you've added custom extensions/limits you will also need to update those.
How To Add PHP Extensions
Some applications, including WordPress plugins/themes may require the use of specific PHP extensions.
By default, we enable most common ones, however you can easily make changes by clicking the checkbox beside the required extension:
You should only enable a PHP extension if you specifically know you need it and should also check that your website still loads after doing so.
You'll also notice the Reset to default button in the top right, which can be used to revert back to our default set if needed (i.e. your website breaks).
If you do not see a required PHP extension, it's important to note the version of PHP as some are deprecated/removed as PHP is updated. Additionally, if there is an extension we do not have enabled on the server, and you're certain it's compatible with a specific version of PHP, feel free to each out to our team so they can evaluate/add it.
How To Modify/Increase PHP Limits
A lot of custom WordPress themes/plugins require specific PHP memory and upload limits.
You can easily customize these based on your needs by clicking the Options tab at the top of the PHP Selector:
This brings up a dashboard where you can define these, per specific PHP version:
As you'll notice at the top, the Current PHP Version shows you specifically what version of PHP you're modifying. You'll want to make sure it says (Current) if you're making changed to your live website.
Remember: PHP options must be changed when selecting a new version of PHP.
For most users, you'll want to leave all of these default except for memory_limit, post_max_size, and upload_max_filesize.
These limits can be increased by clicking the dropdown menu and selecting the new value:
It's important to not set these too high as you could overload your hosting package, especially if you have a script/WordPress plugin that contains a memory leak. As a general rule of thumb, no individual WordPress installation should need a memory limit above 128MB. If you do, it's probably a good idea to check with your plugin/theme vendor to see if they have any issues with their code (it happens more than you think).
Both post_max_size and upload_max_size control the size of an image you can upload through your web browser to your WordPress website. If you need to upload large images, you can increase these values here:
Once you select a value, it's automatically applied, there is no need to save.
As with the memory_limit, the general rule of thumb is to not increase your upload/post limit higher than 64MB. If you have images/files larger than this, it is best to upload via sFTP to prevent a potential website crash.
How To Verify Your PHP Settings
If your application (i.e. WordPress) isn't reflecting the changes you've made inside the PHP Selector, you can easily verify them by creating a PHP info file.
Simply go to cPanel -> File Manager -> public_html -> Create new file -> info.php:
Next, right click over the new file (info.php), and select edit:
This will bring up a dialog box, but just click Edit to continue.
Inside the file, paste the following code and click Save:
// NameHero rocks!
// This shows active PHP settings, defaults to INFO_ALL
// Delete this file once verified for security
Here's a screenshot of how it will look:
Once saved, go to yourdomain.com/info.php and it should look like this:
At the top of my example, you'll notice PHP Version 7.3.21, this should match what's active in cPanel -> Select PHP:
Additionally, any modified limits, such as memory_limit should be reflected in the left column (the right column contains server defaults):
You'll notice I use the "find" option in Chrome to quickly identify it.
If I check cPanel -> PHP Selector -> Options, I can compare it:
If your PHP modifications aren't being reflected
1) Make sure you're not attempting to alter any of these limits outside of cPanel -> Select PHP Version.
Many tutorials around the Internet suggest making PHP modifications inside your .htaccess, by creating a php.ini or user.ini file, or even inside your wp-config.php file for WordPress (real bad method). The PHP Selector used at NameHero is provided by CloudLinux and these files may break the functionality of it.
2) Make sure there is not a php.ini or user.ini file(s) in your /home directory
If you've moved from another web host, it's very common for these files to "come along" with you. Some PHP applications may also contain these, so you should inspect your /home directory to make sure one hasn't been carried over.
Most often, these are inside /home/yourusername or /home/yourusername/public_html but it's best to search everything.
You can easily do this by going to cPanel -> File Manager and searching for php.ini and user.ini (do a search for each):
If you have one (or both) of these files, delete it or rename to something like .php.ini.OLD so it will no longer function.
3) Inspect .htaccess for PHP configurations
cPanel's native PHP selector will write PHP configuration settings inside your .htaccess file.
This is often in your /home/yourusername directory or /home/yourusername/public_html directory, but can differ based on the location of your application.
By default, cPanel's File Manager hides .files (dotfiles) so you'll need to click Settings (at the top right) and then check Show Hidden Files (dotfiles) and Save:
If you see an .htaccess file in your root directory, you should right click, edit, and inspect it for any PHP configuration code. It may look something like this:
You should delete this or comment it out by adding a # in front of the code:
The same goes for any references to PHP memory, max upload, or post limit. Delete those lines or comment them out.
Once completed, you should be able to see your new settings from cPanel -> Select PHP Version reflected. If not, make sure to check for other .htaccess files, commonly in public_html.
4) If using WordPress, check for PHP limits in your wp-config.php file
A really bad practice is to modify PHP limits within the WordPress configuration file.
Eventually this will break your website as PHP will no longer reference this in future versions, but until then, navigate to the directory where WordPress is installed and locate the file wp-config.php (you may use the search function as above).
Right click, edit, and open it up.
Look for code such as this:
define( 'WP_MEMORY_LIMIT', '256M' );
Delete this out and save.
Once you're able to successfully verify all of your PHP settings are correct, you should remove your info.php file for security.
Following these steps should get your PHP settings correct where changes can easily be made inside of cPanel -> Select PHP Version. If you need to make modifications that aren't available inside that interface, please reach out to our Superhero Team to evaluate / activate where possible.