Sunday, 17 March 2013

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

To know the current settings in the server, use the following command:
===
/usr/local/cpanel/bin/rebuild_phpconf --current
====

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. Also, make sure to check whether cgi is enabled in the configure options

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

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

The version will be shown by the php binary.

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

Note: confirm that the php.ini file is present in /usr/local/php-5.3.8/lib directory.Also check if the extension_dir in php.ini for 5.3 is the correct path. That is, /usr/local/php-5.3.8/lib/php/extensions/no-debug-non-zts-20090626.

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

No comments:

Post a Comment

Note: only a member of this blog may post a comment.