Impor­tant set­tings for PHP and Word­Press — The Guide

The most impor­tant set­tings for PHP and Word­Press coop­er­a­tion. The most impor­tant are max_execution_time, memory_limit and upload_max_ (file) size. To run the cur­rent Word­Press instal­la­tion, the cur­rent PHP ver­sion must also be set up accord­ing­ly on the webserver.

Error mes­sages

If error mes­sages, such as.

The uploaded file exceeds the upload_max_filesize directive in php.ini

Then you know that the PHP set­ting (the script­ing lan­guage for Word­Press pro­gram­ming) on your serv­er is not enough.

PHP ver­sion: 8. * is the most advanced. 7.4 Okay

You should use at least PHP ver­sion 7.4 *. Since secu­ri­ty sup­port for this ends on Novem­ber 28, 2022, I rec­om­mend using ver­sion 8.0 (or high­er) imme­di­ate­ly: Secu­ri­ty sup­port for 8.0 does not end until Novem­ber 26, 2023. For the lat­est infor­ma­tion on PHP ver­sion sup­port, see below

The 8 ver­sion is also much more pow­er­ful than the 7 ver­sion — one more rea­son for the change. What can con­tra­dict changes to the cur­rent ver­sion: (ver) old (ete) plu­g­ins or themes. Only: You should pay atten­tion to these com­po­nents in any case and replace them.

Usu­al­ly your provider has to change the PHP ver­sion for your web­space. Please make a sup­port request for this. How­ev­er, with some vir­tu­al host­ing pan­els like Plesk, C‑Panel, etc. you can do this yourself.

How do I find out the cur­rent PHP ver­sion and settings?

The eas­i­est way is to upload via sFTP a file called “phpinfo.php” to your Word­Press root direc­to­ry, which con­tains the fol­low­ing con­tent — if your provider pro­vides a web inter­face (e.g. WebFTP) in advance, cre­ate it direct­ly on the server:

phpinfo ();

Then go to the brows­er and call this file:

And pay atten­tion to some set­tings in this file, unfor­tu­nate­ly these set­tings are quite scat­tered in this file.

php: detailed settings

Pay spe­cial atten­tion to the fol­low­ing three parts in php.ini:

  1. Resource lim­it: “max_execution_time”, “max_input_time” and “memory_limit”.
  2. Data pro­cess­ing: there you will find the “post_max_size” setting
  3. File upload: “upload_max_filesize” is set here.

I would rec­om­mend the fol­low­ing settings:

Min­i­mum setting

Unfor­tu­nate­ly, most servers have default set­tings, such as memory_limit for PHP scripts is still 128 MB (some­times even 64 or 32 MB). This is not enough (not any­more), I rec­om­mend allow­ing at least 256 MB. Below are rea­son­able set­tings that Word­Press and most plu­g­ins should use.

max_execution_time = 300 
max_input_time = 1000
memory_limit = 256M
post_max_size = 128M
upload_max_filesize = 128M

M stands for megy­byte / MB and time (_time) stands for seconds:

  • With these set­tings, a PHP script is allowed to use up to 256 MB of mem­o­ry and run for no longer than 300 sec­onds (= 5 minutes).
  • The image or movie you upload to the media library or send with the form as an attach­ment should not be larg­er than 128 MB .

Opu­lent set­tings: if you can afford it:

But there are also very mem­o­ry-inten­sive plu­g­ins (eg Word­fence), there 512 MB or pos­si­bly even more mem­o­ry lim­it would be even bet­ter. You no longer expe­ri­ence that you no longer see the Word­Press page, but only the PHP error message.

Here php set­tings that pro­vide even more ressou­cren to the scripts:

max_execution_time = 500
max_input_time = 3000
memory_limit = 512M 
post_max_size = 128M 
upload_max_filesize = 128M

How­ev­er, the set­tings may be lim­it­ed, e.g. you can­not allo­cate 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 alter­na­tive, they can change it.

These set­tings are set in php.ini, if not pos­si­ble, set in the .htac­cess file.

Where can I find the php.ini?

Since this is out­side your http­docs direc­to­ry, you will find your HTML file in this direc­to­ry.
If these five val­ues can­not be set in php.ini as described above, they must be entered in the .htac­cess file.

PHP set­tings in .htac­cess

Invis­i­ble .htac­cess files (yes, the dot is part of the file­name) can exist in any direc­to­ry and apply to that direc­to­ry and all its sub­di­rec­to­ries (until pos­si­bly “dep­re­cat­ed” again fur­ther down the line).

If you access your serv­er via sFTP, you may need to spec­i­fy in the set­tings that invis­i­ble files are also dis­played in order to see the .htac­cess file.

After open­ing this file, set the set­tings to the end of the file (or the high­er val­ue list­ed above under “Great”):

max_execution_time = 300 
max_input_time = 1000
memory_limit = 256M
post_max_size = 128M
upload_max_filesize = 128M

Con­clu­sion: check phpinfo.php again.

Final­ly, call the phpinfo.php file again in the brows­er and check the PHP ver­sion (prefer­ably the 7.*) and the set­tings of these five parameters.

Join our list

Sub­scribe to our mail­ing list and get inter­est­ing stuff and updates to your email inbox.

Thank you for subscribing.

Some­thing went wrong.

Leave a Reply

Your email address will not be published. Required fields are marked *