
Getting "Fatal error: Allowed memory size of X bytes exhausted" in WordPress, or unable to upload files because they exceed the size limit? These issues are easily resolved by adjusting PHP.ini settings. This guide covers how to configure PHP.ini on DirectAdmin shared hosting — from the basics to recommended settings for WordPress, WooCommerce, and any CMS.
What is PHP.ini?
PHP.ini is PHP's main configuration file, controlling behavior such as maximum memory usage, maximum upload file size, maximum script execution time, and error reporting. On shared hosting, each virtual host (domain) can have its own PHP.ini, letting you customize PHP settings per site without affecting other accounts on the same server.
Three Ways to Edit PHP.ini on DirectAdmin
Method 1: DirectAdmin PHP Settings Panel
The easiest method — no file editing required:
- Log into DirectAdmin
- Go to Advanced Features → PHP Settings
- Adjust values (memory_limit, upload_max_filesize, etc.) using the form
- Click Save
Method 2: Create php.ini in public_html
Create a file named php.ini inside your public_html folder (or whichever folder runs your site), then add your desired values:
Method 3: Via .htaccess (mod_php / CGI)
Some server configurations support PHP settings through .htaccess:
Note: The .htaccess method works only with mod_php. If your hosting uses PHP-FPM (common on newer DirectAdmin installations), use the php.ini file method instead.
Key PHP.ini Settings Explained
| Setting | Default | WordPress Recommended | Description |
|---|---|---|---|
| memory_limit | 128M | 256M | Maximum memory a PHP script can use |
| upload_max_filesize | 2M | 64M | Maximum size of a single uploaded file |
| post_max_size | 8M | 64M | Maximum POST request size (must exceed upload_max_filesize) |
| max_execution_time | 30 | 300 | Maximum seconds a script can run |
| max_input_time | 60 | 300 | Maximum seconds to parse input data |
| max_input_vars | 1000 | 3000 | Maximum number of input variables (for complex forms) |
Recommended Settings for WordPress
Recommended Settings for WooCommerce
Common PHP.ini Directives on DirectAdmin with Recommended Values
When managing hosting on AsiaGB's DirectAdmin, the PHP directives you actually need to touch usually come down to the five settings below. This table summarizes the standard PHP defaults against the values recommended for WordPress and WooCommerce on shared hosting, so you can configure everything in one pass instead of guessing one value at a time.
| Directive | Default | WordPress | WooCommerce | What it does |
|---|---|---|---|---|
| memory_limit | 128M | 256M | 512M | Memory ceiling a PHP script can use per request — heavy plugins like page builders and backup tools consume the most here |
| upload_max_filesize | 2M | 64M | 128M | Maximum size of a single uploaded file — raise this if you cannot upload theme/plugin zips or high-resolution images |
| post_max_size | 8M | 64M | 128M | Maximum total POST request size — must always be ≥ upload_max_filesize, otherwise large uploads fail even if upload_max_filesize is high enough |
| max_execution_time | 30 | 300 | 600 | Maximum seconds a script may run before being killed — product imports and large database updates need this raised |
| max_input_vars | 1000 | 3000 | 5000 | Maximum number of input variables per request — themes/plugins with long settings pages (hundreds of options) hit 1000 and fail to save all values |
Tip: Always set post_max_size slightly higher than upload_max_filesize (e.g. 64M/68M), because a POST request includes the other form fields too, not just the file itself.
Editing PHP.ini in DirectAdmin (Custom PHP Settings / .user.ini)
Beyond the standard PHP Settings menu, newer DirectAdmin installations running PHP-FPM also support configuration through a .user.ini file, which is more flexible and reliable than .htaccess when your hosting does not use mod_php. You can pick whichever method suits you.
Via the DirectAdmin Custom PHP Settings menu
Some DirectAdmin versions expose a Custom PHP / PHP Settings area where you can type directives directly, without creating a file yourself:
- Log into DirectAdmin and go to Account Manager → Domain Setup, then select the domain
- Open the PHP Version / PHP Settings section for that domain
- Enter your directives in the Custom Settings field, one per line, e.g.
memory_limit=256M - Click Save — values apply immediately to that domain without affecting other domains in the account
Via a .user.ini file (recommended for PHP-FPM)
If your hosting runs PHP-FPM (the default on newer DirectAdmin), create a file named .user.ini in public_html instead of php.ini — DirectAdmin reads it automatically:
; .user.ini — place in public_html
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 68M
max_execution_time = 300
max_input_vars = 3000
Important: Changes to .user.ini do not apply instantly like php.ini, because PHP-FPM caches it according to user_ini.cache_ttl (typically 300 seconds). If you do not see the change, wait ~5 minutes or restart PHP-FPM from DirectAdmin.
Values WordPress / WooCommerce Need
Both WordPress and WooCommerce publish server requirements that list minimum values. Setting them lower may still work but risks errors under heavy load — for example, updating many plugins at once or importing thousands of products.
WordPress (general sites / blogs / corporate)
- memory_limit: 256M — enough for WordPress plus typical themes and plugins (WordPress.org's stated minimum is 64M, but in practice you should set 256M)
- upload_max_filesize / post_max_size: 64M — handles uploading most themes, plugins, and media files
- max_execution_time: 300 — prevents import/export and auto-update jobs from being cut off mid-run
- max_input_vars: 3000 — critical for themes with long Customizer or Theme Options pages
WooCommerce (online stores)
- memory_limit: 512M — stores with hundreds to thousands of products plus payment/shipping plugins clearly need more memory than a plain WordPress site
- upload_max_filesize / post_max_size: 128M — supports importing large product catalogs (CSV) and many product images
- max_execution_time: 600 — product imports and stock syncs can take a long time
- max_input_vars: 5000 — WooCommerce settings pages plus extension plugins carry a large number of variables
WooCommerce has a Status → System Status page in the admin that shows your current PHP values and flags any setting below the recommendation in red. It is faster to check there than opening phpinfo().
Checking Values (phpinfo) + Common Issues (413, white screen, timeout)
After changing values, always confirm they actually took effect — sometimes a value is overridden by the server, or the file sits in the wrong folder. The most accurate check is phpinfo() as described above. Look at the Local Value column (what applies to your site) versus the Master Value (the server-level value).
HTTP 413 Request Entity Too Large
This appears when uploading a large file and the server returns 413 before PHP is even reached. The cause is a limit at the web server level (Nginx/Apache), not just PHP. Raise both upload_max_filesize and post_max_size, and if it persists, ask support to align client_max_body_size (Nginx) accordingly.
White Screen of Death (blank page)
A blank page with no error is often caused by memory_limit running out mid-process. Raise it to 256M or 512M, then temporarily enable display_errors (or check the error log in DirectAdmin) to confirm the real cause. Never leave display_errors on permanently in production.
Maximum execution time exceeded / Gateway Timeout
A script running longer than max_execution_time is killed with a fatal error, while a 504 Gateway Timeout happens at the web server level. Raise max_execution_time to 300–600 for heavy jobs, and consider splitting large imports into smaller batches rather than running them all at once.
Checking Current PHP.ini Values
Create a file named phpinfo.php in public_html to view the actual PHP settings in use:
Visit yourwebsite.com/phpinfo.php and search for the settings you need. Delete this file immediately after checking — leaving it accessible is a security risk.
Common PHP Errors and Fixes
- Fatal error: Allowed memory size exhausted — Increase
memory_limitto 256M or 512M - Maximum file size exceeded — Increase both
upload_max_filesizeandpost_max_sizetogether - Maximum execution time of 30 seconds exceeded — Increase
max_execution_timeto 300 or more for long-running scripts
AsiaGB Hosting supports PHP 7.4, 8.2, and 8.3. You can switch PHP versions from DirectAdmin and configure PHP.ini independently per domain. Plans start at 500 THB/year with SSD storage, 50,000 inodes, and 99% Uptime.
PHP.ini Settings for Other Popular CMS (Joomla, Magento, Laravel)
WordPress and WooCommerce are just two of the many CMS platforms and frameworks running on shared hosting. Other systems also benefit from tuned PHP.ini settings, particularly when processing large datasets or working with heavyweight libraries.
Joomla CMS
Joomla resource requirements are similar to WordPress, especially when many extensions are installed. Recommended values:
; Joomla Recommended
memory_limit = 256M
upload_max_filesize = 32M
post_max_size = 32M
max_execution_time = 300
max_input_vars = 3000
Magento / Adobe Commerce
Magento is a high-resource e-commerce platform. Compiling themes and deploying static content are particularly demanding on both memory and execution time:
; Magento Recommended
memory_limit = 1024M
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 900
max_input_vars = 10000
realpath_cache_size = 10M
realpath_cache_ttl = 7200
Note: Magento on shared hosting often struggles with performance due to resource limits. For full performance, consider a VPS where memory and CPU are fully under your control.
Laravel and Modern PHP Frameworks
Laravel and other modern PHP frameworks (Symfony, CodeIgniter) need reasonable PHP.ini values to run Composer installs and Artisan commands without hitting limits:
; Laravel / PHP Framework
memory_limit = 512M
max_execution_time = 300
max_input_vars = 5000
upload_max_filesize = 64M
post_max_size = 68M
PHP.ini Security-Related Settings
Beyond memory and upload limits, PHP.ini controls several security-relevant directives that you should configure correctly on any production site. Leaving defaults in place can expose server information to attackers or allow error messages to leak sensitive data.
Disable display_errors on Production
The display_errors directive should always be off on live sites. PHP error messages can reveal file paths, database table names, and other sensitive details that attackers can exploit:
; Production Security Settings
display_errors = Off
log_errors = On
error_log = /home/username/logs/php_error.log
expose_php = Off
Secure Session and File Upload Settings
For any site that accepts user file uploads or runs authenticated sessions, these additions harden the default PHP behaviour:
; Session Security
session.cookie_httponly = 1
session.cookie_secure = 1
session.use_strict_mode = 1
session.cookie_samesite = Strict
Tip: Setting expose_php = Off removes the PHP version from HTTP response headers, making it harder for automated scanners to identify your PHP version and target version-specific vulnerabilities.
PHP.ini Configuration: Comparing Hosting Platforms
Every control panel and hosting platform has a slightly different approach to PHP.ini management. The table below summarises the practical methods available on each platform, so you can apply the right technique whether you are on DirectAdmin, cPanel, Plesk, or a VPS.
| Platform / Panel | Primary Method | Alternative | Notes |
|---|---|---|---|
| DirectAdmin (AsiaGB) | PHP Settings Panel | .user.ini in public_html |
PHP-FPM: use .user.ini; CGI: use php.ini |
| cPanel | MultiPHP INI Editor | php.ini via File Manager |
GUI editor produces identical results |
| Plesk | PHP Settings → Custom | php.ini in document root |
Plesk manages PHP-FPM pools separately |
| VPS (Root Access) | Edit /etc/php/8.x/fpm/php.ini |
PHP-FPM Pool config | Full control, no provider policy limits |
If your site needs more than 512M of memory or requires custom PHP configurations that shared hosting cannot provide, AsiaGB VPS gives you full root access starting at 500 THB/month.
Frequently Asked Questions About PHP.ini on DirectAdmin
What's the difference between php.ini and .user.ini — which should I use?
Both work similarly, overriding PHP values at the domain level, but .user.ini is the standard file for PHP-FPM (the default on newer DirectAdmin), while a per-folder php.ini is typically used with CGI/FastCGI PHP. If you are unsure which your hosting runs, try .user.ini first, since it supports PHP-FPM, which is the most common setup today.
I changed values in DirectAdmin but phpinfo still shows the old ones?
Three common causes: (1) the .user.ini file is cached by PHP-FPM — wait ~5 minutes or restart PHP-FPM; (2) the file is in the wrong folder — it must sit in the public_html that actually runs your site; (3) the value is locked at the server level, visible in the Master Value column in phpinfo. In the last case, contact support.
Does setting memory_limit too high waste resources?
memory_limit is a ceiling, not memory reserved permanently. PHP only uses as much memory as a script actually needs. Setting 256M does not mean every request consumes 256M — it just allows genuinely heavy scripts to reach that ceiling. On shared hosting, the maximum you can set is already capped by the provider's policy.
Do my PHP.ini values disappear when I change PHP version in DirectAdmin?
No — the .user.ini or php.ini file in public_html stays intact and applies to the new PHP version immediately. However, verify that your directives are still valid in the newer PHP version, as some may have been deprecated or removed.
Hosting with PHP 7.4 / 8.2 / 8.3
Flexible PHP.ini configuration, high memory limits, and support for WordPress, WooCommerce, and any CMS. Starting at 500 THB/year.
View Hosting Plans