My notes and thoughts about Linux, WordPress, PHP, WPML, Toolset and many more.
This quick tutorial shows how you can override upload_max_filesize
and post_max_size
on a per site basis. This assumes you are using Apache server, PHP-FPM handler and WordPress. This tutorial assumes you have shell access to your server so you can restart Apache or PHP-FPM (this is optional but recommended).
By default, there is only one default php.ini
loaded on a server. Sometimes some virtual sites in your server might need specific configuration values that you don’t want to be applied globally.
These are the steps to fix this:
phpinfo.php
:To determine if you are using PHP-FPM handler is to check the value of Server API. In the above screenshot it’s FPM/FastCGI. So that’s correct.
phpinfo.php
. Scroll down and find the field of $_SERVER['SERVER_SOFTWARE']
. It should contain Apache. See screenshot:.user.ini
with the following settings to override upload_max_filesize
and post_max_size
. Example:1 2 | upload_max_filesize=200M post_max_size=500M |
The above example shows that you want to override upload_max_filesize
with 200 Megabytes and post_max_size
with 500 Megabytes
Make sure its on the root directory of WordPress. Als make sure to put a dot sign before the file name as this is a hidden configuration file like .htaccess
. This is how it looks like when this file is created:
It’s on the same path as the wp-load.php
, etc.
.user.ini
file is created, restart your Apache server and PHP-FPM:1 2 | sudo service php7.0-fpm reload; sudo service apache2 restart; |
It assumes you are using PHP 7.0. If you are using PHP 5.7, simply replace php7.0-fpm with php5.6-fpm.
phpinfo()
output and confirm that the Local value is now correct. This value is meant to be active for the specific site with the .user.ini
and not applied to all sites in your server..user.ini
in your WordPress root directory ). But it will take some time for the settings to take effect. After you have put the correct value in your .user.ini
. You need to refresh your page and wait for like several minutes for the settings to be reflected in your phpinfo. But if you want the fastest results, you will simply need to restart Apache and PHP-FPM.memory_limit
as well. Please read the following guidelines on setting these values correctly:.user.ini
from being publicly viewed by adding these lines to your .htaccess
:1 2 3 4 | <Files .user.ini> Order allow,deny Deny from all </Files> |