# Php.ini & Virtual Hosts

**URL:** <https://www.ruby-forum.com/t/php-ini-virtual-hosts/214160>\
**Category:** NGINX\
**Created:** [November 23, 2011, 2:21pm UTC](https://www.ruby-forum.com/t/php-ini-virtual-hosts/214160 "2011-11-23T14:21:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [November 23, 2011, 2:21pm UTC](https://www.ruby-forum.com/t/php-ini-virtual-hosts/214160/1 "2011-11-23T14:21:58Z")

</div>

Is it possible to define a php.ini file per virtual host. If so, how can  
it be done? Thanks.

–  
Joshua Parker  
[http://www.joshparker.us/](http://www.joshparker.us/)

---

<div class="post-metadata">

**Author:** ![ParkerS\_Joshua](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3d9bf3/32.png) [@ParkerS\_Joshua](https://www.ruby-forum.com/u/ParkerS_Joshua)\
**Post date:** [November 23, 2011, 2:39pm UTC](https://www.ruby-forum.com/t/php-ini-virtual-hosts/214160/2 "2011-11-23T14:39:20Z")

</div>

> Is it possible to define a php.ini file per virtual host. If so, how can it be  
> done? Thanks.

To actually use different php.ini files you will have to spawn seperate  
php processes but you can achieve different settings for  
each virtualhost using a single php.ini file:

1. You can use the [HOST=yourvirtualhost] (  
[PHP: List of php.ini sections - Manual](http://php.net/manual/en/ini.sections.php) ) approach and define the  
settings directly in  
php.ini
2. You can make multiple pools in the FPM configuration (  
[PHP: Configuration - Manual](http://php.net/manual/en/install.fpm.configuration.php) ) and change the  
settings via php\_flag / php\_admin\_value etc directives
3. You can pass the config changes also from nginx using fastcgi\_param  
PHP\_VALUE …
4. Can also use the .user.ini approach  
[PHP: .user.ini files - Manual](http://www.php.net/manual/en/configuration.file.per-user.php)

rr

---

<div class="post-metadata">

**Author:** ![ParkerS\_Joshua](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3d9bf3/32.png) [@ParkerS\_Joshua](https://www.ruby-forum.com/u/ParkerS_Joshua)\
**Post date:** [November 23, 2011, 2:59pm UTC](https://www.ruby-forum.com/t/php-ini-virtual-hosts/214160/3 "2011-11-23T14:59:48Z")

</div>

Thank you very much for this info.

On Wednesday, November 23, 2011, Reinis R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Is it possible to define a php.ini file per virtual host. If so, how can  
> > it be done? Thanks.
> 
> To actually use different php.ini files you will have to spawn seperate  
> php processes but you can achieve different settings for each  
> virtualhost  
> using a single php.ini file:
> 
> 1. You can use the [HOST=yourvirtualhost] (  
> [http://php.net/manual/en/ini.sections.php](http://php.net/manual/en/ini.sections.php) ) approach and define the  
> settings directly in php.ini
> 2. You can make multiple pools in the FPM configuration (  
> [PHP: Configuration - Manual](http://php.net/manual/en/install.fpm.configuration.php) ) and change the  
> settings via php\_flag / php\_admin\_value etc directives
> 3. You can pass the config changes also from nginx using fastcgi\_param  
> PHP\_VALUE …
> 4. Can also use the .user.ini approach  
> [PHP: .user.ini files - Manual](http://www.php.net/manual/en/configuration.file.per-user.php)
> 
> rr
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
[image: Josh Parker WordPress Consultant] [http://www.joshparker.us/](http://www.joshparker.us/)  
Joshua Parker  
WordPress Consultant  
888.255.1798 x701

Consulting Site  
[www.joshparker.us](http://www.joshparker.us)  
[image: Twitter] [http://twitter.com/#!/joshmac](http://twitter.com/#!/joshmac)[image:  
Linkedin][http://www.linkedin.com/in/joshmac](http://www.linkedin.com/in/joshmac)[image:  
Josh Parker :: WordPress Consultant]  
[http://www.joshparker.us/feed/](http://www.joshparker.us/feed/)[image:  
Skype][image: Google+] [http://gplus.to/joshuaparker](http://gplus.to/joshuaparker)[image: WordPress  
Profile] [http://wordpress.org/extend/plugins/profile/parkerj](http://wordpress.org/extend/plugins/profile/parkerj)[image:  
[About.me](http://About.me)] [http://about.me/joshuaparker](http://about.me/joshuaparker)[image:  
Gravatar][http://en.gravatar.com/joshmac3](http://en.gravatar.com/joshmac3)
