Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Does PHP read php.ini on each request or do I have to restart Apache for php to be aware of changes on php.ini?

share|improve this question

1 Answer 1

You will need to restart - the config files including php.ini are read when the master process starts & actual web pages are served by child apache processes cloned (forked) off of the master.

share|improve this answer
2  
A "graceful" restart should be sufficient if you want to avoid any risk of client errors. –  daveadams Feb 4 '12 at 16:20
    
@daveadams: great, what's a graceful restart? I just restart it with a XAMPP command line, which I guess kills the process and re launches it. It's just a local dev server though, son no worries for angry clients, but would like to know anyway. –  Petruza Feb 4 '12 at 20:32
    
@Devin: So apache actually calls php once and it keeps running and only spawns childs for each request? –  Petruza Feb 4 '12 at 20:33
    
To be precise - it loads the config files (like httpd.conf and php.ini) once on start up. PHP scripts are begun anew each time a PHP script is run - there is no cross-request memory in a PHP script execution the way there is in something like mod_perl. –  Devin Ceartas Feb 4 '12 at 21:27
1  
@Petruza: graceful just means it won't kill any processes that are in the middle of serving a page to a user. For dev stuff, your method is fine, but generally whatever Apache script you are using to specify "start" "stop" or "restart" in, you can just say "graceful" instead and each process will wait for any ongoing work to complete before dying and respawning with the new settings. –  daveadams Feb 14 '12 at 20:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.