How to Fix cPanel PHP ini Configuration Errors
In this tutorial, you'll learn about How to Fix cPanel PHP ini Configuration Errors. We cover key concepts, practical examples, and best practices.
The Problem
PHP settings are not applying:
Changes to php.ini have no effect.
or:
Fatal error: Allowed memory size exhausted.
Quick Fix
Step 1: Find the correct php.ini
# Create a PHP file with:
<?php phpinfo(); ?>
Look for "Loaded Configuration File" to find the active php.ini.
Or use the command line:
php -i | grep "Loaded Configuration File"
Step 2: Use cPanel's MultiPHP INI Editor
cPanel > Software > MultiPHP INI Editor > Select your domain
Change settings:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
Step 3: Edit the correct .htaccess
If MultiPHP is not available, use .htaccess:
php_value memory_limit 256M
php_value upload_max_filesize 64M
php_value post_max_size 64M
Step 4: Apply changes to a specific PHP version
# For PHP 8.0:
/opt/cpanel/ea-php80/root/etc/php.ini
# For PHP 8.1:
/opt/cpanel/ea-php81/root/etc/php.ini
Step 5: Restart PHP-FPM
/scripts/restartsrv_apache_php_fpm
Step 6: Verify the changes
Create test.php:
<?php
echo 'Memory: ' . ini_get('memory_limit');
echo 'Upload: ' . ini_get('upload_max_filesize');
?>
Prevention
- Use MultiPHP INI Editor in cPanel for per-domain settings.
- Restart PHP-FPM after changing php.ini.
- Test changes with phpinfo() after applying.
Common Mistakes with php ini
- Misunderstanding that
Stringis[Char]with poor performance for large text operations - Using
foldlinstead offoldl'causing stack overflow on large lists - Forgetting
deriving (Show, Eq)on custom data types needed for debugging
These mistakes appear frequently in real-world CPANEL code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro