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: www.mysite.com
- Document root: /var/www/mysite.com/web
2. Steps
- Copy global php.ini file to /var/www/mysite.com folder
+ For Debian / Ubuntu
cp /etc/php5/apache2/php.ini /var/www/mysite.com/
+ For CentOS/Redhat/Fedora
cp /etc/php.ini /var/www/mysite.com/
- 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 mysite.com
<VirtualHost *:80>
[...]
PHPINIDir /var/www/mysite.com
[...]
</VirtualHost>
- Restart your Apache
+ For Debian/Ubuntu
/etc/init.d/apache2 restart
+ For CentOS/Redhat/Fedora
/etc/init.d/httpd restart