php.ini settings not taking effect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

php.ini settings not taking effect

Post by josh »

I set max_execution_time = 200 in php.ini

Code: Select all

 
# cat /etc/php.ini | grep max_execution
max_execution_time = 200     ; Maximum execution time of each script, in seconds
phpinfo shows that is the file it does load

Code: Select all

# php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
yet it shows a value of 0 for that value

Code: Select all

 
# php -i | grep max_execution
max_execution_time => 0 => 0
What's going on?
Last edited by josh on Wed Nov 11, 2009 4:41 am, edited 1 time in total.
urooj786
Forum Newbie
Posts: 12
Joined: Mon Nov 09, 2009 11:56 pm

Re: max_execution_time

Post by urooj786 »

use this function---

set_time_limit(200);
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: max_execution_time

Post by josh »

I could.. but that doesn't explain it. Anyways I am reinstalling linux on that machine so we will see if it is something in the code.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: max_execution_time

Post by Eran »

There might be additional configuration files overriding this value. Check in your phpinfo output under "Scan this dir for additional .ini files " for paths that it might include.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: max_execution_time

Post by josh »

There was one included .ini and it only had like 2 lines, neither of which overrided. What was wierd is the value looks like a multi-dimensional array. Anyways I just finished restoring my svn repository, will test out now on a different distro
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: max_execution_time

Post by Eran »

Check also for overriding htaccess files which can use the php_flag operator to override it
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: max_execution_time

Post by josh »

Hmm well I just installed a new distro on a fresh drive and its working, there wasnt any overriden php.ini settings in the code and no .htaccess, oh well. go figure
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: max_execution_time

Post by josh »

Well the whole root of this problem was a PHP bug I was trying to work around. It seems like PHP is getting buggier and buggier. This is on a new system, compiled PHP myself from 5.3

Code: Select all

# php -i | grep memory_limit
memory_limit => 128M => 128M
[root@localhost k12]# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini
[root@localhost k12]# cat /usr/local/lib/php.ini | grep memory_limit
memory_limit = 1024MB;
 

Code: Select all

 
phpinfo()
PHP Version => 5.3.0
 
System => Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64
Build Date => Aug  1 2005 20:52:21
Configure Command =>  './configure'  '--with-mysqli=mysqlnd' '--with-mysql=mysqlnd'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => /usr/local/lib/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20090626
PHP Extension => 20090626
Zend Extension => 220090626
Zend Extension Build => API220090626,NTS
PHP Extension Build => API20090626,NTS
Debug Build => no
Thread Safety => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
Registered PHP Streams => php, file, glob, data, http, ftp, phar
Registered Stream Socket Transports => tcp, udp, unix, udg
Registered Stream Filters => convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk
 
 
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
 
Should I report it?

There is no .htaccess file because this is the command line
There is no .php scripts calling any functions, as you see I am just invoking php -i so it should only read settings from php.ini

I also can't get xdebug to load. I tried installing with pecl, I tried phpiz'ing and compiling myself, settings simply do not take affect.

The other problem I was having is when scripts finished executing memory usage and cpu went up to 100% and PHP never finished the script. It was doing this line on an exit() call. If I changed exit() to return() it happened on the ?> (closing tag) line. Since I reformatted that seems to have gone away, thankfully.
Last edited by josh on Wed Nov 11, 2009 4:45 am, edited 1 time in total.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: php.ini settings not taking effect

Post by Eran »

just to be on the safe side, you restarted apache after changing the settings, right?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: php.ini settings not taking effect

Post by josh »

It's CLI, there is no apache running. I'm setting up a cruise control server. Its finally working after 4 days of debugging various stuff. But I have to use ini_set() calls and I can't get xdebug to load for the code coverage.

I'm recompiling right now but when its done I'm going to try to run PHP's unit tests
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: php.ini settings not taking effect

Post by josh »

I had to copy an en entire sample php.ini and then splice my settings into the correct places.

I guess if you just have a php.ini file that says memory_limit = 150MB for instance it will not be read

Although commenting out the "

Code: Select all

" at the top had no effect, and the rest of the "section headers" are just comments. What gives? Is this documented behavior?
Post Reply