Compiling custom php to the server and adding it to cpanel suphp

Download the latest version of php. As of now the latest version of php is php-5.3.8.

cd /usr/src
wget http://us.php.net/get/php-5.3.8.tar.gz/from/this/mirror
tar -zvxf php-5.3.8.tar.gz
cd php-5.3.8

Collect the configuration options from the remote server and configure it using those options on the new server. Make sure the prefix is set as /usr/local/php-5.3.8 and the existing prefix option is removed from the compiling options.

./configure –prefix=/usr/local/php-5.3.8 –other-options

If you get any errors like missing libxml2, you can install libxml2

make
make install
/usr/local/php-5.3.8/bin/php -v

The version will be shown by the php binary. Install corresponding ZendOptimizer, ioncube, eaccelerator etc if needed. ZendOptimizer:-

 

Adding new php binary to suphp: Add the line in the suphp.conf file to include the newly compiled php binary to suphp

vi /opt/suphp/etc/suphp.conf
[handlers]
application/x-httpd-php5.3=”php:/usr/local/php-5.3.8/bin/php-cgi”

Add the following lines in the file /usr/local/apache/conf/includes/pre_main_2.conf if only the domain with the username “username” needs custom php.

<Directory “/usr/local/php-5.3.8/bin”>
Allow from All
</Directory>
<Directory /home/username/public_html>
suPHP_AddHandler application/x-httpd-php5.3
AddType application/x-httpd-php5.3 .php
</Directory>

Restart apache if there is no error

/etc/rc.d/init.d/httpd configtest
/etc/rc.d/init.d/httpd restart

If the new php should be set as global php, then edit the file /usr/local/apache/conf/php.conf as follows.

<Directory “/usr/local/php-5.3.8/bin”>
Allow from All
</Directory>
<Directory />
suPHP_AddHandler application/x-httpd-php5.3
AddType application/x-httpd-php5.3 .php
</Directory>

Restart apache if there is no error

/etc/rc.d/init.d/httpd configtest
/etc/rc.d/init.d/httpd restart

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: