Memory Limit
WordPress can be very memory intensive, especially if you use a lot of plugins or a page builder. The WordPres default is 40MB for the frontend. In my experience thi is very small, even for basic websites. Set this to 256MB or more if you can or you could get the infamous “Fatal error: Allowed memory size exhausted” error very often.
Upload Max File Size
This values sets the maximum size of a file user can upload to media gallery. I usually set this to 64MB. If you will handle video upload, this value will need to be bigger.
Post Max Size
This must be equal or greater to upload_max_filesize so PHP can handle uploads properly.
Max Execution Time
How much time PHP will wait to a single script run. If it come to this value without finish the processing it returns a timeout error. I usually set this to 300s (5min) for development as I usually made some imports or longer updates. For production, 1 minute (60s) could be fine.
Max Input Time
How much PHP will wait for a file upload (or form submission). This correlates to your expected upload_max_filesize and user internet connection. For images, 60s can be enough. If you permit video or bigger files, set this to a longer value (5 or 10 minutes. 300 or 600 seconds, respectivelly).
Max Input Vars
This values sets the maximum number of variables PHP can receive in a single request. Page builders can use a lot. So set this to 2000 or more.
So, until now we have a php.ini file like following:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
max_input_vars = 3000
OPcache Settings
OPcache is a in memory cache. By default it loads PHP compiled code to memory and loads from than as needed in the program lifecycle.
You can use a plugin to use OPcache to store WordPress Object cache (besides PHP cache), like Docklet. That way it works very similar to use something like memcached or redis cache.
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=2
TODO: include some more details of Docklet
Its not working!
Depending on your environment you will encounter some dificulties to change this values.
By default, PHP load the php.ini files in configured directories.
If you are running apache, you can try put the values in a .htaccess file in the root of your project.
php_value memory_limit 256M
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
php_value max_input_vars 3000
Maybe your host prevents overrides. In this case you can talk to them. If they refuse to change, you can try to go with permitted value or change host for some VPS (TODO: include a link to how to wp on vps).
Links:
Leave a Reply