I am currently trying to locate the correct php.ini file to edit it and restart apache so the changes will take place and I'm stumped.
I have found three different php.ini files (no idea why there are three) this is how I found the files
$ sudo find / -name php.ini
/etc/php5/cli/php.ini
/etc/php5/apache2/php.ini
/etc/php5/cgi/php.ini
I also did....
$ sudo php -i | grep 'Configuration File'
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
I changed all of them (just to be sure) to the settings I wanted.
I restarted apache using
sudo service apache2 restart
The results...
* Restarting web server apache2
I reloaded the page and it showed that the php.ini file was not updated.
I know this because I used
echo ini_get('post_max_size');
Which was supposed to be changed to 20M but was still only 2M
I tried rebooting my computer thinking maybe that would stop the apache server and reload the php.ini file with the correct setting, but alas that attempt also failed.
Is there any chance there could be another php.ini file that could be interfering?
The three files you have there are each meant for different uses.
/etc/php/5.6/cli/php.ini
is for the CLI PHP program, which you found by runningphp
on the terminal./etc/php/5.6/cgi/php.ini
is for the php-cgi system which isn't specifically used in this setup./etc/php/5.6/apache2/php.ini
is for the PHP plugin used by Apache. This is the one you need to edit for changes to be applied for your Apache setup which utilizes the in-built PHP module to Apache./etc/php/5.6/fpm/php.ini
is for thephp5-fpm
processor, which is a fastcgi-compatible 'wrapper' for PHP processing (such as to hand off from NGINX tophp5-fpm
) and runs as a standalone process on the system (unlike the Apache PHP plugin)To find which
php.ini
the CLI is using you can run:Example output:
Try running a script containing this snippet in your browser
<?php phpinfo(); ?>
and then try to search for something like Loaded Configuration File. This entry specifies the php.ini your PHP uses in your Apache server.for php7 ubuntu 16.4
You can find the file being used by running this on terminal:
just use
<?= phpinfo() ?>
and read :I am on LAMP stack on Amazon Lightsail and the location of the correct php.ini file for my Ubuntu server is: