Compiling custom php for a domain in the Apache mod fcgid environment

See if the server has got mod_fcgid installed. You can verify this by checking the following line in the file

FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php

If it is enabled, to create a custom php for a domain follow the steps below.

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.

-----------
download libxml2-git-snapshot.tar.gz
tar -zxvf libxml2-git-snapshot.tar.gz
cd libxml2-2.7.8
./configure --prefix=/usr/local/mylibxml
make
make install
-----------

make
make install

/usr/local/php-5.3/bin/php-cgi -v

PHP 5.3.8 (cgi-fcgi) (built: Jan 12 2012 01:33:10)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with the ionCube PHP Loader v4.0.12, Copyright (c) 2002-2011, by ionCube Ltd.

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

Based on the php version you should install the ZendOptimizer. If the php version is equal or less than php-5.2.X go for Zend Optimizer. If the php is greater than or equal to 5.3.X use ZendGuard.

Download : ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

tar -zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
cd ZendOptimizer-3.3.9-linux-glibc23-x86_64
install.sh

Once the php binary has been created, copy it to the home directory of the user. This is to be done as the apache server will be having suexec enabled. In this case if we are going to execute a binary fro inside a VH entry, it needs to have the user permission.

Eg: To enable custom php for the user gsideweb (gsideweb.com)

cp /usr/local/php-5.3/bin/php-cgi /home/gsideweb/php-cgi
chown /home/gsideweb/php-cgi

We need to specify this binary in the apache VH. In the filw /usr/local/apache/conf/httpd.conf go to the Virtualhost section of domain gsideweb.com, you can see the following line. For any VH entry modification, you need to create a config file in the path and add it there. The directory itslef may be absent.

Include “/usr/local/apache/conf/userdata/std/2/gsideweb/gsideweb.com/*.conf”

Create a custom config file

mkdir -p /usr/local/apache/conf/userdata/std/2/gsideweb/gsideweb.com/
touch /usr/local/apache/conf/userdata/std/2/gsideweb/gsideweb.com/custom_php.conf

Add the following line to custom_php.conf

FCGIWrapper /home/gsideweb/php-cgi .php

Restart apache and check with a phpinfo page.

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: