I have been trying for two days to increase the max filesize for file uploads via php to 10M from the default 2M. I change the php.ini file that is referenced by phpinfo to
I had exactly the same problem and solved it using these steps:
When running the following command on my server
php --ini
I got the following path of my php.ini
Loaded Configuration File: /etc/php/7.0/cli/php.ini
I kept on making changes in this php.ini file, but none of the changes took effect. I then created a file called info.php in my /var/www/html directory and added the following code
<?php
phpinfo();
?>
Then I opened the file in my browser http://example.com/info.php, where I saw that the actual loaded php.ini file was in a different directory
Loaded Configuration File /etc/php/7.0/apache2/php.ini
When I made changes to the php.ini file inside of this directory, all the changes took effect. In summary make sure that you run the phpinfo(); function to make sure of the actual php.ini file which php uses.
service apache2 reload
needs to be run as root, even if it does not appear to fail without root. Running sudo service apache2 reload
works. This is in Ubuntu 14.04.
You might also need to increase the maximum size of a post:
post_max_size=10M
Try that.
Maybe you find 2 directories for php.ini files.
If you search where php.ini is using cli like php --ini
maybe it show you /etc/php/7.1/cli/php.ini
, but thereis another folder to php-fpm
found in /etc/php/7.1/fpm/php.ini
and you need to create your new ini file under conf.d
folder like /etc/php/7.1/fpm/conf.d/30-user.ini
and if you need a ini file to cli command line you need to put your ini file under /etc/php/7.1/cli/conf.d/30-user.ini
After reading great @Jekis's answer, I solved the same issue for Fedora distribution (it's the same thing, just different path):
After evaluting phpinfo();
output I found out that other .ini
files are stored in: /etc/php.d
directory
In /etc/php.d
I created a new file - 40-user.ini
. I added upload_max_filesize
and other settings that I wanted to change
Then I restarted apache (httpd)
And then changes were picked up.
If you php.ini resides somewhere like /etc/php/7.*/fpm/php.ini
- then modify it as needed and instead of sudo service apache2 restart
go with service php7.1-fpm restart