Windows – Linux – Mac OSX Guides

How to have custom php.ini for each virtual host

Note: This is for Apache + mod_php


1. Assumptions

I have a website that I don’t want to use global php.ini file, i want to use my own custom php.ini

– Website:

– Document root: /var/www/


2. Steps

– Copy global php.ini file to /var/www/ folder

+ For Debian / Ubuntu

cp /etc/php5/apache2/php.ini /var/www/


+ For CentOS/Redhat/Fedora

cp /etc/php.ini /var/www/


– Edit your php.ini file as you want and save it

– Now tell Apache that you want to use new php.ini file by edit the VirtualHost for

<VirtualHost *:80>
PHPINIDir /var/www/


– Restart your Apache

+ For Debian/Ubuntu

/etc/init.d/apache2 restart


+ For CentOS/Redhat/Fedora

/etc/init.d/httpd restart

Tagged with:     , , ,

Related Articles

Loading Facebook Comments ...

1 Comment

Post your comments

Your email address will not be published. Required fields are marked *