
We recently searched high and low for an elegant way to define PHP directives on a per domain basis. We use Lighttpd web server, and therefore .htaccess rules and configurations are unavailable. The reason for the requirement of granular PHP directive settings, is we have clients that want to host multiple web applications on a single cloud server, but want PHP to perform slightly different for each of their applications. A concrete example of this is, a PHP application may be quite old, and require register_globals on (we know, this is bad practice and we frown upon it), while the rest of the clients applications can have register_globals off. Another great example for us internally, is to be able to define a PHP log file for each domain independently, instead of a single monstrous PHP log file for the entire cloud server.
PHP user ini files to the rescue! User PHP ini files allow you to define PHP directives on a per directory basis, which is extremely powerful and flexible. The only caveat is that you must be running PHP 5.3.0 or greater. To get user php ini files running simply modify your main/base php.ini file and add the following two directives:
user_ini.filename = .php.user.ini user_ini.cache_ttl = 60
The first directive, user_ini.filename specifies the file name that PHP searches for in each directory to process PHP directives. If set to an empty string, PHP doesn’t scan at all. The default is .user.ini, we prefer .php.user.ini, but you may use whatever file name structure you wish. The second directive user_ini.cache_ttl controls how often user INI files are re-read. The default is 300 seconds (5 minutes), but we prefer a slightly faster refresh, so our user_ini.cache_ttl is 60 (1 minute).
Once the above two directives are in your main/base php.ini, simply create your user ini files, and put whatever PHP directives you want to override in the files. You may have to wait up to user_ini.cache_ttl for your custom directives to take effect, but you will NOT have to restart your web server; wooo hoo!
If you have any questions or further comments, don’t be shy; let us know.




Running lighttpd and php here. Needed exactly this hint for my setup. Thanks very much for getting me posting this.
Thanks buddy! really nice information.
well
I have a server running nginx, and a drupal site. I put a .user.ini file into the directory of one of my modules, but it is still caching the php in that directory. I have xcache running and in the .user.ini i have the command xcache.cacher=0 to disable caching of this directory.
How can I test that this file is even being read?
Thanks
Ο τομέας αυτός φαίνεται να πάρετε ένα καλό ποσό των επισκεπτών. Πώς μπορείτε να πάρετε την κυκλοφορία σε αυτό; Προσφέρει μια ωραία μοναδική περιστροφή στα πράγματα. Υποθέτω ότι έχουν κάτι πραγματικά ή ουσιαστικά για να αναφερθώ είναι το πιο σημαντικό πράγμα.
Semmi bajom a cikk, de nem értek egyet néhány pontot néhány extenct. Én valószínűleg egy kisebbségi, bár, lol. Köszönöm megosztására.
Είναι πραγματικά ένα δροσερό και χρήσιμο κομμάτι των πληροφοριών . Είμαι ικανοποιημένος που αυτό το κοινό χρήσιμες πληροφορίες μαζί μας . Παρακαλώ μείνετε μαζί μας ενημέρωσε όπως αυτό. Ευχαριστίες για τη διανομή .
Ευχαριστώ εκ των προτέρων και καλή τύχη ! : )
hi!!!
Thank you for sharing it ! Very nice, Peace.Excellent information, thank you very much. Congratulations on the quality of the website. Greetings from Chile.
I don’t even know how I finished up right here, but I believed this publish was great. I don’t understand who you might be but definitely you are going to a well-known blogger for those who are not already
Cheers!
oakley oil drum sunglasses