display_errors = Off, expose_php = Off, allow_url_include = Off, with memory_limit, upload_max_filesize and post_max_size set to what you need. On cPanel hosting, change them in Select PHP Version or MultiPHP INI Editor without touching files; on a server without a panel, in the php.ini for the PHP version in use.The settings that matter #
| Setting | Suggested value | Why |
|---|---|---|
display_errors |
Off on a live site | Error messages reveal file paths and database names |
log_errors |
On | Errors go to an error_log file instead of the screen |
expose_php |
Off | The PHP version is not advertised in response headers |
allow_url_include |
Off | Blocks including files from remote URLs, an old attack technique |
allow_url_fopen |
Usually On | Many plugins need it; only close it if you are sure |
memory_limit |
Per site | WordPress with heavy plugins needs more than small values |
upload_max_filesize and post_max_size |
post larger than upload | Otherwise uploads fail without a clear message |
max_execution_time |
Moderate | A huge value lets stuck scripts eat resources |
disable_functions |
Per server policy | Disabling functions such as exec and shell_exec makes running commands harder for an attacker |
Where to edit them #
| Environment | Tool |
|---|---|
| Hyyat Host hosting (CloudLinux) | cPanel, then Select PHP Version, then Options |
| cPanel without CloudLinux | cPanel, then MultiPHP INI Editor |
| A cPanel server admin, per PHP version | WHM, then Software, then MultiPHP INI Editor |
| A server without a panel | The php.ini for the PHP version in use; find it with php --ini |

After editing the file by hand, restart PHP-FPM or the web server so it reads the new values. In cPanel the tools apply the change themselves.
How to check the value actually in use #
Create a temporary file containing <?php phpinfo(); in the site folder, open it, find the setting, then delete the file immediately, as it reveals a lot about the server. From the command line: php -i | grep memory_limit, bearing in mind command-line settings may differ from the site’s.
Protecting php.ini itself #
- Do not put php.ini or .user.ini in a public folder with permissions that let a browser read it.
- 644 is enough; no one but the owner needs write access.
- On shared hosting, never upload a full php.ini from an unknown source; it may override the server’s security settings.
php.ini questions #
I edited php.ini and nothing changed
The site may run a different PHP version or a different config file. Check the loaded file path with phpinfo.
Should I turn on display_errors to fix a problem?
Only briefly while you work; better to read error_log instead.
What is the difference between php.ini and .user.ini?
.user.ini changes some settings for one folder only, and works with PHP-FPM and similar handlers.
Can I see current PHP settings in WHM?
Yes. MultiPHP INI Editor shows each version’s current values in Basic Mode.
- Raising the phpMyAdmin Database Import Size on a cPanel Server: The Right Setting in WHM
- Tuning Apache on a cPanel Server: Global Configuration, MPM, PHP-FPM, Compression and Caching
- Change Your PHP Version in cPanel and Turn On Extensions: MultiPHP and Select PHP Version
- Securing a cPanel Server: A Practical 10-Step Checklist in Order, from Updates to Backups