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

  1. In "Select PHP Version", you'll see a dropdown menu with available versions
  2. Select the version you want to use (recommended: PHP 8.1 or higher for better performance and security)
  3. 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:

  1. On the same page, you'll see a list of available PHP extensions
  2. Check or uncheck the extensions you need
  3. 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
  4. Click "Save"

Configure PHP options (php.ini)

To adjust PHP limits and configurations:

  1. In "Select PHP Version", look for the "Options" tab
  2. Or search for "PHP Configuration Editor" in cPanel
  3. 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
  4. Modify values according to your needs
  5. 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:

  1. In "Select PHP Version", look for the "PHP per domain" option
  2. Select the domain
  3. Choose the specific PHP version for that domain
  4. 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:

  1. In cPanel, search for "PHP Info"
  2. Or create a phpinfo.php file in public_html with 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_limit in PHP configuration
  • Or add in wp-config.php (for WordPress): define('WP_MEMORY_LIMIT', '256M');

Error: "Upload file size exceeds limit"

  • Increase upload_max_filesize and post_max_size
  • Make sure post_max_size is greater than upload_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:

  1. In cPanel, search for "PHP Configuration Editor"
  2. Choose "Advanced" mode
  3. Edit values directly
  4. 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:

Was this answer helpful? 0 Users Found This Useful (0 Votes)