PHP Configuration

    Configure PHP settings and select PHP versions for optimal performance

    Selecting PHP Version

    cPanel allows you to select different PHP versions for your website. Newer versions offer better performance and security, but some applications may require specific versions.

    Step 1: Log into cPanel

    Access your cPanel control panel.

    Step 2: Navigate to PHP Selector

    Find the "Software" section and click "Select PHP Version" or "MultiPHP Manager".

    Step 3: Select Your Domain

    Choose the domain you want to configure from the list.

    Step 4: Choose PHP Version

    Select your desired PHP version from the dropdown menu and click "Apply".

    Recommended PHP Versions

    PHP 8.2 or 8.3

    Recommended

    Latest versions with best performance and security features.

    PHP 8.1

    Stable and widely supported by most applications.

    PHP 7.4

    Older but still supported by many legacy applications.

    PHP 7.3 and below

    End of life - Not recommended for production use.

    WordPress Compatibility

    WordPress officially supports PHP 7.4 and higher, but PHP 8.0+ is recommended for best performance. Check your theme and plugin compatibility before upgrading.

    PHP Settings and Limits

    You can adjust various PHP settings to optimize your website:

    memory_limit

    Maximum amount of memory a script can use. Default is usually 128M or 256M. Increase for memory-intensive applications.

    max_execution_time

    Maximum time (in seconds) a script can run. Default is 30. Increase for long-running scripts like imports.

    post_max_size

    Maximum size of POST data. Important for file uploads. Should be larger than upload_max_filesize.

    upload_max_filesize

    Maximum size of uploaded files. Default is often 2M. Increase for larger file uploads.

    max_input_vars

    Maximum number of input variables. Increase if you see "max input vars exceeded" errors.

    Modifying PHP Settings

    Method 1: Via MultiPHP INI Editor (Easiest)

    1. In cPanel, go to "Software" → "MultiPHP INI Editor"
    2. Select your domain or use "Home Directory" for all domains
    3. Choose "Basic Mode" or "Editor Mode"
    4. In Basic Mode, adjust sliders for common settings
    5. In Editor Mode, add custom directives
    6. Click "Apply"

    Method 2: Via php.ini File

    Create or edit php.ini in your website's root directory:

    memory_limit = 256M
    max_execution_time = 300
    post_max_size = 64M
    upload_max_filesize = 64M
    max_input_vars = 3000

    Method 3: Via .htaccess

    Add to .htaccess file (only works with PHP as CGI/FastCGI):

    php_value memory_limit 256M
    php_value max_execution_time 300
    php_value post_max_size 64M
    php_value upload_max_filesize 64M

    Method 4: Via wp-config.php (WordPress)

    Add to wp-config.php before "That's all, stop editing!":

    define('WP_MEMORY_LIMIT', '256M');
    define('WP_MAX_MEMORY_LIMIT', '512M');

    PHP Extensions

    Enable or disable PHP extensions for your domain:

    1. Go to "Select PHP Version" in cPanel
    2. Click "Extensions" or switch to extensions tab
    3. Check/uncheck extensions as needed
    4. Click "Save"

    Common Extensions:

    mysqli

    MySQL database

    gd

    Image processing

    curl

    URL handling

    zip

    ZIP files

    mbstring

    Multibyte strings

    xml

    XML processing

    PHP Handlers

    Different ways PHP can be executed on the server:

    FastCGI

    Recommended

    Best performance and security. Each user's PHP processes run under their own username.

    CGI

    Basic CGI handler. Slower than FastCGI but widely compatible.

    mod_php (DSO)

    Runs as Apache module. Fast but less secure in shared environments.

    Checking Current PHP Configuration

    Create phpinfo() File

    1. Create a file named info.php in public_html
    2. Add the following code:
    <?php phpinfo(); ?>
    1. Visit yourdomain.com/info.php
    2. View complete PHP configuration
    3. Important: Delete this file after checking for security

    Troubleshooting

    500 Internal Server Error

    • • Check PHP syntax errors
    • • Verify .htaccess syntax
    • • Check PHP error logs
    • • Ensure PHP version compatibility

    Memory Limit Exceeded

    • • Increase memory_limit in php.ini
    • • Optimize code to use less memory
    • • Check for memory leaks

    Upload Size Exceeded

    • • Increase upload_max_filesize
    • • Increase post_max_size
    • • Ensure post_max_size is larger than upload_max_filesize

    Best Practices

    • • Use the latest stable PHP version when possible
    • • Test PHP version changes in staging before production
    • • Keep PHP settings minimal - only increase what you need
    • • Monitor PHP error logs regularly