changing php.ini has no effect on my EC2 instance's PHP config

20,150

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:

enter image description here

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 :)

Share:
20,150
naico777
Author by

naico777

Updated on July 21, 2022

Comments

  • naico777
    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
    naico777 over 10 years
    Hi 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
    Matthew Oakley about 5 years
    Oh, you are brilliant! This is the exact answer to my problem. This should be all over the internet...
  • Oved Yavine
    Oved Yavine almost 5 years
    This is what I needed. Drove me nuts
  • Rob Craig
    Rob Craig almost 5 years
    Worked 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
    Tom over 4 years
    Pure genius. Thank you. Confirm works for AWS EC2 Linux 2 AMI after updating /etc/php.ini.
  • sotn
    sotn over 3 years
    Spent the better half of a day hunting this solution down. Thx!
  • Saitama
    Saitama almost 3 years
    What if I'm using nginx?
  • Arvind K.
    Arvind K. almost 3 years
    I think you have to replace httpd with nginx in ‘sudo systemctl restart httpd.service’. You have to figure that out.
  • Matthew Oakley
    Matthew Oakley almost 3 years
    What'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..