changing php.ini has no effect on my EC2 instance's PHP config
Solution 1
Since PHP on Amazon Linux ran with FPM/FastCGI I had to do:
sudo systemctl restart php-fpm.service
before restarting apache, i.e
sudo systemctl restart httpd.service
Solution 2
Which config file are you editing? When you do a phpinfo()
what is the path shown under Loaded Configuration File
? Edit the php.ini
that it says it is loading & your changes should be reflected.
If you don’t know how phpinfo()
works, just create a file on your server called something like:
phpinfo_test.php
In that file place this code:
<?php
phpinfo();
?>
Now load phpinfo_test.php
from that web server.
Solution 3
This is very late, but for those of you who don't know how to handle this problem, you want to restart apache for it to reflect the changes:
sudo service httpd restart
Solution 4
I want to leave the method that worked for me here for others that run into my same problem in language I would appreciate at my level of expertise. I found the location of the php.ini file with the following command in the terminal connected to the server:
$ php --ini
You will get the following output:
Change directories to the one specified as "Loaded Configuration File." In the example it is /etc/
Type cd /etc
into the command line and hit enter.
To override readonly add sudo
before vi php.ini
or copy and paste
sudo vi php.ini
into the command line and hit enter.
Find the place where you would like to make changes and arrow the cursor over it. Press the i
key to make changes to the document and when you are done hit the ESC
key.
To save the changes and exit vi, enter
:x
I hope that helps. Links to some of the resources that helped me cobble together my solution are below:
https://forums.aws.amazon.com/message.jspa?messageID=391689
http://www.geekyboy.com/archives/629
http://www.lagmonster.org/docs/vi.html
https://unix.stackexchange.com/questions/3334/how-do-i-quit-from-vi
Solution 5
I just spent some time and discovered, that there were repeat php.ini settings in the end of php.ini file in section AWS Settings. Including upload size and session duration.
Just scroll to the end of php.ini file. Hope this helps someone :)
naico777
Updated on July 21, 2022Comments
-
naico777 almost 2 years
I'm running an Apache server in a micro instance from Amazon AWS, and I need to change the session duration and the max upload limit.
When I edit
php.ini
and restart Apache, changes don't show in Apache.I wasn't able to find any info on this.
What can I do? is there any file overriding
php.ini
that you know of? -
naico777 over 10 yearsHi thank you for answering, Loaded Configuration File es /etc/php5/apache2/php.ini. I edited that ne and nothing happens. I also checked: Additional .ini files parsed: /etc/php5/apache2/conf.d/curl.ini, /etc/php5/apache2/conf.d/gd.ini, /etc/php5/apache2/conf.d/mcrypt.ini, /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini, /etc/php5/apache2/conf.d/zeromq.ini. But none of those files has anything to do with it. I also did a find inside the server looking for other .ini and .conf files, but no luck.
-
Matthew Oakley about 5 yearsOh, you are brilliant! This is the exact answer to my problem. This should be all over the internet...
-
Oved Yavine almost 5 yearsThis is what I needed. Drove me nuts
-
Rob Craig almost 5 yearsWorked for me on a 2019 Amazon Linux 2 AMI EC2 - just adding keywords for Google so this answer isn't 15th down the page. Thanks!
-
Tom over 4 yearsPure genius. Thank you. Confirm works for AWS EC2 Linux 2 AMI after updating /etc/php.ini.
-
sotn over 3 yearsSpent the better half of a day hunting this solution down. Thx!
-
Saitama almost 3 yearsWhat if I'm using nginx?
-
Arvind K. almost 3 yearsI think you have to replace httpd with nginx in ‘sudo systemctl restart httpd.service’. You have to figure that out.
-
Matthew Oakley almost 3 yearsWhat's really funny is that I was looking for this answer... and noticed that I already commented on this answer two years ago... and forgotten. See above..