Nice example. but this way user's might put custom php.ini files into their homefolder and get whatever configuration they want. Here is how we do it - not sure if this might overlap some other "howto". I think it very obvious how to use this howto to run any version of PHP (you have to compile it yourself, of course).
1. First create custom php.ini.
Code:
mkdir -p /usr/local/apache/conf/custom_php/DOMAINNAME/
cp /usr/local/lib/php.ini /usr/local/apache/conf/custom_php/DOMAINNAME/
Modify copied php.ini.
2. Create custom PHP wrapper.
Code:
cd /usr/local/cpanel/cgi-sys/
cp php5 php5_DOMAINNAME
chown root.wheel php5_DOMAINNAME
3. Edit custom PHP wrapper to use custom php.ini
Inside php5_DOMAINNAME change "exec" line to the following:
Code:
exec /usr/bin/php -c /usr/local/apache/conf/custom_php/DOMAINNAME/php.ini
4. Set to use custom wrapper by webserver
Code:
mkdir -p /usr/local/apache/conf/userdata/std/2/USERNAME/DOMAINNAME
cd /usr/local/apache/conf/userdata/std/2/USERNAME/DOMAINNAME
vi custom.conf
And add the following line:
Code:
FCGIWrapper /usr/local/cpanel/cgi-sys/php5_DOMAINNAME .php
5. Configure httpd.conf - remember to check, that custom configuration file, that you created in step 4 is being included into apache config file. In /usr/local/apache/conf/httpd.conf inside website VirtualHost there should be line like this:
Code:
Include "/usr/local/apache/conf/userdata/std/2/USERNAME/DOMAINNAME/*.conf"
6. Restart webserver and check that website is using correct php.ini. Errors may be in /usr/local/apache/logs/error_log and in /usr/local/apache/logs/suexec_log
7. Important notes
If you are running FastCGI and right now - you are planning to turn off safe_mode, please remember, that we have it because of one reason: we are unable to change open_basedir and restrict customer to a single folder. As with this setup, explained above, we have created separate php.ini file for a single website, we actually can change and set open_basedir. Conclusion: if you are disabling safe_mode, you must set open_basedir in custom php.ini! Search for open_basedir and change to:
Code:
open_basedir = "/home/USERNAME:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp"