This information is helpful for hosting companies that want to run PHP 4 & 5 on the same cPanel server. After this, Hosting costumers / cPanel users should choose what version of PHP will they use on theirs scripts.
You should consider some implications on your server performance, but webhosts are using because they don't need two server to run the different PHP versions for different costumers.
How to run PHP 4 and 5 on the same Cpanel server
1. Login to you cPanel server as root using ssh
2. Check the compiler and remove and re-create cpphpbuild directory
# /scripts/checkccompiler
# rm -rf /home/cpphpbuild
# mkdir /home/cpphpbuild
# cd /home/cpphpbuild
3. Download PHP5 and extract it
# wget http://us2.php.net/get/php-5.2.4.tar.gz/from/this/mirror
# tar zfx php-5.2.4.tar.gz
# cd php-5.2.4
4. Download, build and install php5.gen.cpanel
echo “#define HAVE_SENDMAIL 1″ >> /home/cpphpbuild/php-5.2.4/main/php_config.h
# wget http://www.elix.us/tutorials/php5.gen.cpanel
# chmod 700 php5.gen.cpanel
# ./php5.gen.cpanel
# make
If you get following error:
Got this error:
gcc: /usr/lib/mysql/libmysqlclient.so: No such file or directory
make: *** [sapi/cgi/php-cgi] Error 1
Then try this:
# cd /usr/lib
cp libmysqlclient.* /usr/lib/mysql/
And then try again #make
# make install
5. Now you should move the files and finish the configuration
# cp -f /usr/local/php5/bin/php5 /usr/local/cpanel/cgi-sys/php5
# chown root:wheel /usr/local/cpanel/cgi-sys/php5 # cp -p /home/cpphpbuild/php-5.2.4/php.ini-recommended /usr/local/php5/lib/php.ini
# chown root.root /usr/local/php5/lib/php.ini
# chmod 644 /usr/local/php5/lib/php.ini
# echo “cgi.fix_pathinfo = 1 ; needed for CGI/FastCGI mode” >> /usr/local/php5/lib/php.ini
Configure httpd.conf file, save and exit.
# nano /usr/local/apache/conf/httpd.conf
Scroll down (better use the built-in search) to the "
There we should to add index.php5 after index.jp, but before index.php4. Result would looks like this:
Continue editing. Find the "AddType application/x-httpd-php .phtml" and after it add this:
Action application/x-httpd-php5 "/cgi-sys/php5"
AddHandler application/x-httpd-php5 .php5
This is the directives for Apache to use own php5 for files with extensions .php5
Check if we could find this line "ScriptAlias /cgi-sys/ /usr/local/cpanel/cgi-sys/"
If not - add it or our directive will not work. By default cPanel add this line. Just to warn you.
Save the file and quit.
Verify that you not broke the Apache config by running:
service httpd configtest
You SHOULD to get "Syntax OK" at the end and possible some minor warnings about "NameVirtualHost directive" - it is OK.
Warning: if you get ERROR - DO NOT RESTART APACHE AND LOCATE THE ISSUE. Otherwise Apache will not start at all!
When you make sure it is OK restart the Apache:
service httpd stop
service httpd startssl
Check that Apache come ok:
lynx --dump http://localhost/whm-server-status;
It will show you the Apache status.
Well, I should congratulate you - you have done it!
Now create php files with the name "phpinfo.php" and "phpinfo.php5" and add the following code to the file
If you have done successfully, both files should show proper version.
Enjoy:)
How to run PHP 4 and 5 on Cpanel
Posted by Mayur's BLOG
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment