15

Hi, Apache with php works well, but none of the changes I make in php.ini have effect, I've even delete all the contents of the file, then restart Apache, and run phpinfo() and surprisingly everything continues working well.

The file I'm editing is the one that appears in the phpinfo() like "Loaded Configuration File". (/etc/php5/apache2/php.ini)

P.S. I'm running Ubuntu 9.04 and PHP 5.2

More Details:

I'm restarting with sudo /etc/init.d/apache2 restart, I've also tried sudo /etc/init.d/apache2 stop, and then start, at restarting I get:

  • Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName [ OK ]

"which php" did not produce any results.

My installation of PHP was done using Synaptic Package Manager, choosing "Mark Packages by task" and then LAMP server.

I don't have any clue of what to do...

3
  • Didn't know that if could run without a php.ini. Thanks a lot to all of you.
    – MrAn3
    Jun 6, 2009 at 23:08
  • for that error, make sure that the hostname is set correctly Jan 5, 2011 at 10:01
  • I am facing the same problem. You seem to have solved yours using the responses of this thread but... I am not sure how. Could you elaborate a bit more on what did the trick for you? Thank you in advance for your help. Sep 3, 2012 at 18:56

12 Answers 12

18

I've had the same problem with an earlier version of Ubuntu (12.04), Apache 2.2.22 and php5-fpm fastCGI flavour of PHP. Doing

service apache2 restart 

isn't enough, because it just restarts the http server: you have to issue also the command

service php5-fpm restart

to have the application server restarted and PHP read the php.ini file again.

3
  • @ACarter no problem, just wanted to add my personal contribute to the KB :) May 27, 2013 at 9:48
  • didnt work for me Failed to restart php5-fpm.service: Unit php5-fpm.service failed to load: No such file or directory.
    – theArc
    Apr 24, 2016 at 5:58
  • or php7.4-fpm, php8.0-fpm, ... (check what correct name is for your version: service --status-all | grep fpm) Sep 25, 2022 at 8:18
9

Looks like you are changing the wrong php.ini - Check the location of php.ini that is given in the phpinfo() output! This will show you the php.ini that is actually used.

Also check if the Apache restart really succeeded. ;)

1
  • The above answer is right, wenn you have installed the libapache2-mod-php5filter module, the php.ini of this file is the right file to modify, changes on the normal php.ini file will do nothing. (i had the same problem installing moodle and mahara on one system, moodle needs this package!).
    – user168566
    Apr 8, 2013 at 16:41
8

Make sure you're editing the correct file. There are several files for different circumstances all (at least on Jaunty) nestled in /etc/php5/

For apache+mod_php, you want /etc/php5/apache2/php.ini

1

Verify that you are not using 2 php.ini files - one for the web server module and another one for the CLI version.

1

It continues to work because PHP will run without a php.ini file, but it runs with whatever options were turned on at compile time.

What changes are you making that are not showing up in the phpinfo() output?

1
  • +1 Excellent! Long searched for this! Jul 6, 2011 at 16:34
1

Try

sudo aptitude install libapache2-mod-php5filter 

than using config in /etc/php5/apache2filter/php.ini instead

1

I had the same problem, and for those answering before me, NO I'm not editing the wrong file.

I'm running Ubuntu 10.04 running Nginx and my PHP install uses PHP-FPM. PHP-FPM seems to be what causes the problem.

To solve the problem, I run php-fpm from the command-line. (Just type in php-fpm and hit enter.)

In my case, this gives me a few warnings about modules not found, and then exits.

After this, phpinfo shows the correct values, without restarting the webserver.

I hope this helps.

0

Open up the terminal and type

which php

Then you'll know which version you have and you can go from there. I would also be checking to see that you did properly restart your apache server

0

I am using Ubuntu 10.04 (lucid). In order for changes on the php.ini to work, you must reboot the system. Restarting apache is not enough.

0

In config.php change ServerName="127.0.1.1" to

ServerName="Localhost"
0

Do find / -type f -name "php.ini" This will output all files named php.ini.

Find out which one you're using, usually apache2/php.ini.$ Edit and enjoy.

phpinfo(); might help you out to know which one is used. lsof could also help you out.

0

I'm not sure why, but service apache2 reload appeared to succeed but did not result in any changes being reflected in phpinfo output. Running sudo service apache2 reload works. This is in Ubuntu 14.04.

You must log in to answer this question.