3

I can't get my server to obey the settings from php.ini (I'm trying to change memory_limit and upload_max_filesize). As far as I can tell, I'm editing the correct file. phpinfo() gives:

Loaded Configuration File   /etc/php.ini

The file permission is 644. There are also some extra .ini files on /etc/php.d, but none include any of the keys I'm trying to change. No matter what I do, phpinfo reports the default values on both "Local" and "Master" columns.

I also scanned my Apache config files, but found nothing related to PHP (besides loading the PHP module). The only way I was able to change those settings was by adding some php_value lines to my .htaccess.

Is there something obvious I'm missing?

This is a virtual server, and I can perform root commands with sudo. I'm running Apache 2.1.3 and PHP 5.3.3. System info (from uname -a) is:

 Linux sesctbapp01 2.6.18-308.1.1.el5 #1 SMP Wed Mar 7 04:16:51 EST 2012 x86_64
10
  • 1
    Did you restart apache after you made the changes?
    – Zypher
    Jul 11, 2012 at 19:45
  • Yes, I tried both restarting and just "reloading".
    – bfavaretto
    Jul 11, 2012 at 19:52
  • Do the following and post back what it finds: find / -name php.ini
    – drumkiller
    Jul 12, 2012 at 13:19
  • The output was just /etc/php.ini.
    – bfavaretto
    Jul 12, 2012 at 15:09
  • 1
    It can either be that those values are overwritten by the starter script (if using php-fpm) using the -d option or that the PHP script is setting it's own limit within the PHP files. Beside that, no idea. One thing to keep in mind is that not all PHP modes support setting values via htqccess - just to mention that.
    – MaddinXx
    Oct 2, 2013 at 5:26

4 Answers 4

2

write a file in your webserver called test.php:

<? phpinfo(); ?>

Then open it in your browser

there is a section

Directive   Local Value Master Value

where you see the values, of all variables and where they are set: Local Value means, set in .htaccess or inside the php-script with ini_set()

also try http://php.net/manual/de/function.ini-get-all.php to find out the source of the content of your variables.

i once had a stupid error, where i tried to set upload_max_filesize to 200M: i wrote "200MB" in php.ini, but it must be just "200M" php interprets the incorrect value "200MB" as 0. Maybe some of this helps

5
  • Thanks, but this problem is still a mystery to me. It like if some other ini file is overriding mine, but I can't find any. Also, although phpinfo() reports my ini file as "Loaded Configuration File", the values under "Master" are always the defaults. The only way I can override them is from .htaccess, while I really wanted to define all my settings from php.ini...
    – bfavaretto
    Sep 17, 2012 at 2:43
  • maybe there is a bad typo in the php.ini so it is ignored completely and all default php values are used instead. can you post your php.ini somewhere?
    – rubo77
    Sep 17, 2012 at 2:49
  • Hm, I haven't thought of that! Here is my php.ini: pastebin.com/KxwjA3K1
    – bfavaretto
    Sep 17, 2012 at 2:55
  • can i see the output of your phpinfo() somewhere?
    – rubo77
    Sep 17, 2012 at 17:30
  • 1
    and try moving the php.ini file somewhere else and restart apache. if you see an error, you will know, that apache tries to use that file, if there is no error, you should look somewhere else. normally php.ini is at /etc/php5/apache2/php.ini
    – rubo77
    Sep 17, 2012 at 17:34
2

If using php-fpm (don´t know if thats your case tough) it is not enough to restart apache, you have to restart php-fpm.

For example, on an Ubuntu 20.04 server and php 7.4 fpm, i had to

/etc/init.d/php7.4-fpm restart

in order for my php.ini to get obeyed.

1

Run php -i in the terminal and it will flag if you have any syntax errors in your php.ini. Such errors make Apache to not parse (ignore) directives quietly.

0

I was struggling with the same problem yesterday. I established there was only one php.ini on the system, phpinfo() reported that indeed the correct php.ini was being used for configuration, I stopped httpd checked that all instances had been killed then restarted it, but php was still using the same values. This had to mean that another process was reading and storing the original values in php.ini. Search for php in the process listing revealed multiple instances of php-fpm. Tried killing it and then restarting apache. That solved the problem. Tried more more changes in php.ini and tried using systemctl reload php-fpm and yes of course it worked. I don't know when the switch away from mod_php was made, apparently years ago but somehow I've missed it and over 90% of the servers I manage still use mod_php. None of the guides I've read for applications like Moodle mention ifpm. All say make the change and restart apache none of them mention restarting fpm, but there you go. I'm guessing many of the queries raised on sites like serverfault are down this issue. systemctl start httpd starts the fpm daemon in additon to httpd but systemctl stop httpd does not stop php-fpm nor does sytemctl restart httpd restart it and a new systemctl start httpd will unsurprisingly just leave the old version running.

So the quick way to make changes is to modify php.ini and and then run systemctl reload php-fpm no need to touch the httpd daemon.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .