Wednesday, April 10, 2013

Is it possible to compile php 4 and php5 on a cPanel server? If it is, how?

 Make sure we have Apache installed and workind with php4.  we would need to compile php 5. To do this use the SSH sessing logged as root.Then execute preparation commands
cd /home/src
wget url to php5 download
tar xfzv  file
cd extracted file
Make sure that we enabled Sendmail support:
echo "#define HAVE_SENDMAIL 1" >> /home/cpphpbuild/php-5.2.3/main/php_config.h
configure php with these supports
./configure --prefix=/usr/local/php5 --exec-prefix=/usr/local/php5 --program-suffix=5 --with-xml --enable-bcmath --enable-calendar --enable-ftp --with-gd --enable-exif --with-jpeg-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr/X11R6 --with-imap --with-imap-ssl --with-kerberos --enable-mbstring --with-mbstring=all --enable-mbstr-enc-trans --with-mcrypt --with-mhash --enable-magic-quotes --with-mysql=/usr --with-openssl --enable-discard-path --with-pear --enable-sockets --enable-track-vars --with-ttf --with-freetype-dir=/usr --enable-versioning --with-zlib --with-pspell --with-gettext --enable-inline-optimization --disable-debug --enable-force-cgi-redirect --enable-discard-path
then make and make install
 run the cPanel script to complete
The compiled version of php should be copied to the cPanel cgi-sys:
cp -f /usr/local/php5/bin/php-cgi5 /usr/local/cpanel/cgi-sys/php5
chown root:wheel /usr/local/cpanel/cgi-sys/php5
Our installation has no php.ini file yet.
copy the default php.ini and edit it if needed:
cp -p /home/cpphpbuild/php-5.2.3/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
Now we need to add several lines to Apache.
Run editor
vim  /usr/local/apache/conf/httpd.conf
<IfModule mod_dir.c>
DirectoryIndex index.html index.wml index.cgi index.shtml index.jsp index.js index.php5 iindex.php4 index.php3 index.php index.phtml ndex.htm default.htm default.html home.htm
This to allow index.php5 as index file.
 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
 "ScriptAlias /cgi-sys/ /usr/local/cpanel/cgi-sys/"
 add it or our directive will not work. By default cPanel add this line
wrapper file in the /usr/local/cpanel/cgi-sys/php5 with the following content:
# This will fake the name & path and hide the /usr/local/cpanel/cgi-sys/php5 path!
export PWD=`echo $PATH_TRANSLATED|egrep -o "(.*?/)"`
if [ -f "$PWD/php.ini" ]; then
exec /usr/local/cpanel/cgi-sys/php5.bin -c $PWD
exec /usr/local/cpanel/cgi-sys/php5.bin
Save the file and change the permissons:
chown root:wheel /usr/local/cpanel/cgi-sys/php5*;
chmod 755 /usr/local/cpanel/cgi-sys/php5*;

No comments:

Post a Comment