Here is a possible solution for a way to switch between php4/5/6 on a per domain basis.
------------
First of all: This was originally not created by me however the person left the company and I have permission to post this here, thus the way some of the things that have been done here is not how I would originally do it none the less.
Second: You have to make sure that your server is secure by allowing fastcgi and that you set permissions in a safe way accross the board.
Lastly, if you set permissions higher than 755 anywhere in the /cgi-bin/ folder or on the executables needed you will run into a lot of problems.
Custom php.ini for each domain goes into the domain's /cgi-bin/ folder
Lastly, I do not supply the php versions, just a means of making it possible to switch between more than one. It is also possible to edit the code to switch between lets say mod_php4 and mod_php5 if you want or even between mod_php5 and mod_suphp
As far as I know suphp can handle multiple versions of php if configured via /etc/suphp.conf however I have never tried this and is up to you if you want to try and get that to work.
PHP Manager Screenshot:
http://plesk02.glodns.net/pleskphpmanager.png
Download:
http://plesk02.glodns.net/phpmanager032.tgz
When you download this archive, it already contains the file structure as we haev it on our servers.
After extracting these files there are a few steps you need to follow to make sure it wil work.
Step1: Set up fastcgi scripts and default php.ini files.
I have these located in /usr/local/scripts
Check that your php binary is the cgi version for example:
[root@$$$$$]# /usr/local/php448-fcgi/bin/php -v
PHP 4.4.8 (cgi-fcgi) (built: Mar 14 2008 12:56:04)
Copyright (c) 1997-2008 The PHP Group
The edit the /usr/local/scripts/php4.fcgi to look like this:
[root@$$$$$]# cat /usr/local/scripts/php4.fcgi
#!/bin/sh
PHP_FCGI_CHILDREN=2
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /usr/local/php448-fcgi/bin/php
Next edit /usr/local/scripts/php4.ini to what you want for defaults, I symlink my /usr/local/php448-fcgi/etc/php.ini to this, but this file also gets copied to the clients cgi-bin folder so that if he wants to edit it, its there and he can just rename it to php.ini and the php will pick that up instead. We have way too many clients that need specific settings and this is the easiest way to do this.
Repeat this step for each php version you want to enable on the php manager
Step2: Double check the plesk wrapper
Go to /usr/local/psa/admin/bin and run the command "ls -lsah | grep phpmng"
From this you will see where it is symlinked to. I realized that my centos4 and centos5 boxes this file has a different name, I don't know why but on Centos5 I had to delete this file and recreate it via:
ln -s ../sbin/wrapper phpmng
Step3: Configure phpmanager's access to the plesk sql db and which versions you want
I use nano as my editor
nano /usr/local/psa/admin/plib/phpmngdb.php
Supply a user that can access the psa db on the mysql server.
Also define the versions of php you have, as well as which ones to enable.
Just for clarification, the default php is the server default, and when you set to this the php manager basically just delete all the settings it created on the domain.
Step4: Add the PHP manager icon to all the domains
- Log into the plesk control panel with the admin account
- Go to "server" on the left, then to "Custom buttons" on the right
- Click on "Add New Custom Button"
- Fill in the details, use the following as guidelines:
Button labe: PHP Manager
Location: Domain Owners Desktop/homepage
Background iamge: your own icon that looks like the php icon
url: /domains/phpmanager.php
Tick "include domain id" / "&dom_id=<dom_id> (ps. I want to change this to read from the php session variables instead later)
Context help tip: PHP Version Management
Also tick: Open url in CP
Also tick: visible to all sub-logins (if you want clients to be able to control this)