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

Cpanel Server with CentOS.

The purpose of this custom php from source is to enable two modules pdo and gd for drupal installation, which I failed to activate on the cpanel server from commandline and my cpanel license was expired.

1.Download PHP
#cd /usr/src/
#wget “http://php.net/get/php-5.4.7.tar.bz2/from/in.php.net/mirror”
#mv mirror php-5.4.7.tar.bz2
#tar xvjf php-5.4.7.tar.bz2
#cd /usr/src/php-5.4.7

Compile & Install
#./configure –prefix=/usr/local/php-5.4.7 –with-pdo-mysql  –with-gd
#make
#make install

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.4=”/usr/local/php-5.4.7/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.4.7/bin”>
Allow from All
</Directory>
<Directory /home/username/public_html>
suPHP_AddHandler application/x-httpd-php5.4
AddType application/x-httpd-php5.4 .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.4
AddType application/x-httpd-php5.4 .php
</Directory>

Restart apache if there is no error

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

source article for Reference.

Advertisements

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