Configure PHP in cPanel
Why configure PHP?
PHP is the programming language that runs most dynamic websites (WordPress, Joomla, etc.). Configuring PHP correctly in cPanel allows you to:
- Choose the PHP version you want to use
- Adjust memory limits, execution time and file sizes
- Enable or disable PHP extensions
- Optimize your site's performance
See current PHP version
1. Access cPanel
- Go to your cPanel panel
- Log in with your credentials
2. See PHP information
On the cPanel main page, look for the "Software" section and click on "Select PHP Version".
You can also search for it using the search box at the top of cPanel.
At the top you'll see the current PHP version and you can change it.
Change PHP version
1. Select version
- In "Select PHP Version", you'll see a dropdown menu with available versions
- Select the version you want to use (recommended: PHP 8.1 or higher for better performance and security)
- Click "Set as current"
Note: Some applications may require specific PHP versions. Check your application requirements before changing.
2. Configure PHP extensions
After selecting the version, you can enable or disable extensions:
- On the same page, you'll see a list of available PHP extensions
- Check or uncheck the extensions you need
- Common extensions include:
- mysqli: For improved MySQL connections
- gd: For image manipulation
- curl: For making HTTP requests
- zip: For compressing and extracting files
- mbstring: For multibyte character handling
- xml: For XML processing
- Click "Save"
Configure PHP options (php.ini)
To adjust PHP limits and configurations:
- In "Select PHP Version", look for the "Options" tab
- Or search for "PHP Configuration Editor" in cPanel
- You'll see options like:
- memory_limit: Memory limit (e.g., 256M, 512M)
- upload_max_filesize: Maximum file upload size (e.g., 64M)
- post_max_size: Maximum POST data size (must be greater than upload_max_filesize)
- max_execution_time: Maximum script execution time (in seconds)
- max_input_time: Maximum time to process input data
- max_input_vars: Maximum number of input variables
- Modify values according to your needs
- Click "Save"
Recommended configurations
For small/medium WordPress sites:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
max_input_vars = 3000
For large sites or with many plugins:
memory_limit = 512M
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 600
max_input_time = 600
max_input_vars = 5000
Configure PHP per domain
If you have multiple domains and want to use different PHP versions:
- In "Select PHP Version", look for the "PHP per domain" option
- Select the domain
- Choose the specific PHP version for that domain
- Save changes
This allows you to use PHP 8.1 for one domain and PHP 7.4 for another, for example.
See PHP information (phpinfo)
To see all PHP configuration information:
- In cPanel, search for "PHP Info"
- Or create a
phpinfo.phpfile inpublic_htmlwith this content:
<?php
phpinfo();
?>
Access https://yourdomain.com/phpinfo.php to see all information.
Important: Delete this file after reviewing it for security.
Configure error reporting
For development, you can enable showing errors. For production, disable them:
In the php.ini file or in .htaccess:
# For development (show errors)
display_errors = On
error_reporting = E_ALL
# For production (hide errors)
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors = On
Common problems
Error: "Fatal error: Allowed memory size exhausted"
- Increase
memory_limitin PHP configuration - Or add in
wp-config.php(for WordPress):define('WP_MEMORY_LIMIT', '256M');
Error: "Upload file size exceeds limit"
- Increase
upload_max_filesizeandpost_max_size - Make sure
post_max_sizeis greater thanupload_max_filesize
Error: "Maximum execution time exceeded"
- Increase
max_execution_time - Or optimize your code to be more efficient
PHP extension not available
- Verify the extension is enabled in "Select PHP Version"
- Some extensions may not be available in all PHP versions
Advanced configuration
Edit php.ini directly
If you need to edit php.ini directly:
- In cPanel, search for "PHP Configuration Editor"
- Choose "Advanced" mode
- Edit values directly
- Save changes
Use .user.ini (alternative to php.ini)
You can create a .user.ini file in public_html for site-specific configurations:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
This file will apply only to that directory and subdirectories.
Tips
- Use current versions: PHP 8.1+ offers better performance and security
- Enable only necessary extensions: Disable extensions you don't use
- Adjust as needed: Don't increase limits more than necessary
- Test changes: Test changes in a development environment first
- Monitor performance: Review how changes affect performance
- Document changes: Keep a record of configurations you change
Need help?
If you're having trouble configuring PHP in cPanel, open a ticket from the billing.baires.host panel or contact us for support.
You can also reach us through our social media:
- Instagram: @baires_host
- Discord (active support): https://discord.gg/dzjauatAFN
- Linktree: https://linktr.ee/baires.host