Important settings for PHP and WordPress — The Guide
The most important settings for PHP and WordPress cooperation. The most important are max_execution_time, memory_limit and upload_max_ (file) size. To run the current WordPress installation, the current PHP version must also be set up accordingly on the webserver.
Error messages
If error messages, such as.
The uploaded file exceeds the upload_max_filesize directive in php.ini
Then you know that the PHP setting (the scripting language for WordPress programming) on your server is not enough.
PHP version: 8. * is the most advanced. 7.4 Okay
You should use at least PHP version 7.4 *. Since security support for this ends on November 28, 2022, I recommend using version 8.0 (or higher) immediately: Security support for 8.0 does not end until November 26, 2023. For the latest information on PHP version support, see below
http://php.net/supported-versions.php
The 8 version is also much more powerful than the 7 version — one more reason for the change. What can contradict changes to the current version: (ver) old (ete) plugins or themes. Only: You should pay attention to these components in any case and replace them.
Usually your provider has to change the PHP version for your webspace. Please make a support request for this. However, with some virtual hosting panels like Plesk, C‑Panel, etc. you can do this yourself.
How do I find out the current PHP version and settings?
The easiest way is to upload via sFTP a file called “phpinfo.php” to your WordPress root directory, which contains the following content — if your provider provides a web interface (e.g. WebFTP) in advance, create it directly on the server:
<?php
phpinfo ();
?>
Then go to the browser and call this file:
https://www.exemple.com/phpinfo.php
And pay attention to some settings in this file, unfortunately these settings are quite scattered in this file.
php: detailed settings
Pay special attention to the following three parts in php.ini:
- Resource limit: “max_execution_time”, “max_input_time” and “memory_limit”.
- Data processing: there you will find the “post_max_size” setting
- File upload: “upload_max_filesize” is set here.
I would recommend the following settings:
Minimum setting
Unfortunately, most servers have default settings, such as memory_limit for PHP scripts is still 128 MB (sometimes even 64 or 32 MB). This is not enough (not anymore), I recommend allowing at least 256 MB. Below are reasonable settings that WordPress and most plugins should use.
max_execution_time = 300
max_input_time = 1000
memory_limit = 256M
post_max_size = 128M
upload_max_filesize = 128M
M stands for megybyte / MB and time (_time) stands for seconds:
- With these settings, a PHP script is allowed to use up to 256 MB of memory and run for no longer than 300 seconds (= 5 minutes).
- The image or movie you upload to the media library or send with the form as an attachment should not be larger than 128 MB .
Opulent settings: if you can afford it:
But there are also very memory-intensive plugins (eg Wordfence), there 512 MB or possibly even more memory limit would be even better. You no longer experience that you no longer see the WordPress page, but only the PHP error message.
Here php settings that provide even more ressoucren to the scripts:
max_execution_time = 500
max_input_time = 3000
memory_limit = 512M
post_max_size = 128M
upload_max_filesize = 128M
However, the settings may be limited, e.g. you cannot allocate more than 128 MB to the PHP process (memory_limit = 128M). In this case you have to talk to the provider — if they can’t offer you an alternative, they can change it.
These settings are set in php.ini, if not possible, set in the .htaccess file.
Where can I find the php.ini?
Since this is outside your httpdocs directory, you will find your HTML file in this directory.
If these five values cannot be set in php.ini as described above, they must be entered in the .htaccess file.
PHP settings in .htaccess
Invisible .htaccess files (yes, the dot is part of the filename) can exist in any directory and apply to that directory and all its subdirectories (until possibly “deprecated” again further down the line).
If you access your server via sFTP, you may need to specify in the settings that invisible files are also displayed in order to see the .htaccess file.
After opening this file, set the settings to the end of the file (or the higher value listed above under “Great”):
max_execution_time = 300
max_input_time = 1000
memory_limit = 256M
post_max_size = 128M
upload_max_filesize = 128M
Conclusion: check phpinfo.php again.
Finally, call the phpinfo.php file again in the browser and check the PHP version (preferably the 7.*) and the settings of these five parameters.
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.