How To Specify A Custom php.ini For A Web Site (Apache2 With mod_php)
How To Specify A Custom php.ini For A Web Site (Apache2 With mod_php)Version 1.0 This short article explains how you can specify a custom php.ini for a web site running on Apache2 with mod_php. That way, each web site can have its own php.ini instead of having to use the server's default one. I do not issue any guarantee that this will work for you!
1 Preliminary NoteI'm using the web site www.example.com here with the document root /var/www/web1/web here. If you want to learn how to configure a custom php.ini for a web site using Apache + mod_fcgid + PHP, take a look at chapter 5 on http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-debian-etch-p2.
2 Getting Details About Your PHP InstallationWe will now create a small PHP file (info.php) in the document root and call it in a browser. The file will display lots of useful details about our PHP installation, such as the used php.ini file. vi /var/www/web1/web/info.php
Now we call that file in a browser (e.g. http://www.example.com/info.php): As you see, the web site is currently using the /etc/php5/apache2/php.ini file.
3 Custom php.ini For Each Web SiteI will copy the default php.ini (/etc/php5/apache2/php.ini on Debian/Ubuntu; /etc/php.ini on Fedora/CentOS) to the /var/www/web1/ directory and make www.example.com use the php.ini from the /var/www/web1/ directory: Debian/Ubuntu: cp /etc/php5/apache2/php.ini /var/www/web1/ Fedora/CentOS: cp /etc/php.ini /var/www/web1/ (You can now modify /var/www/web1/php.ini to your likings.) Then open the vhost configuration for the www.example.com web site and add a PHPINIDir line to it:
PHPINIDir must contain the directory where the php.ini file for the web site is located. Restart Apache afterwards: Debian/Ubuntu: /etc/init.d/apache2 restart Fedora/CentOS: /etc/init.d/httpd restart Now call the info.php file again in a browser (http://www.example.com/info.php): The Configuration File (php.ini) Path line should now show the new php.ini.
4 Links
|





Recent comments
11 hours 1 min ago
1 day 5 hours ago
1 day 7 hours ago
1 day 7 hours ago
1 day 10 hours ago
1 day 11 hours ago
2 days 3 hours ago
2 days 4 hours ago
2 days 6 hours ago
2 days 7 hours ago