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?


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.

  • 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
  • 2
    @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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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