Drupal 7 compiling php 5.3 with fpm for centos/fedora on the same machine as php 5.2

This is a brief note assuming you know the missing bits (like how to download and explode php etc)

download php source code

use this configure line
./configure --prefix=/usr/local/php5.3 --enable-fpm --with-mcrypt --enable-mbstring --with-curl --disable-debug --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-mbregex --with-mcrypt --enable-zip --with-pcre-regex --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysql_nd --with-config-file-path=/etc/php5.3/nginx/ --with-config-file-scan-dir=/etc/php5.3/nginx/conf.d --with-gd --with-jpeg-dir=/usr/local/lib --with-freetype-dir=/usr/local/lib --enable-gd-native-ttf --with-imap --with-imap-ssl --with-kerberos --with-openssl

You may need to link the kerberos library:

sudo ln -s /usr/lib64/ /usr/kerberos/lib

note:
mysqlnd in the mysql sections is the bundled mysql code not using mysql libraries

mysql pdo may require you to create the following:
sudo ln -s `locate mysql.sock` /tmp/mysql.sock
Start the process
to start, make sure you’re using the full path else it may find a php-fpm in your path

$ sudo /usr/local/php5.3/sbin/php-fpm

the output of ps will look like this:

root      3905     1  0 10:45 ?      00:00:00 php-fpm: master process (/usr/local/php5.3/etc/php-fpm.conf)
nobody    3906  3905  0 10:45 ?        00:00:00 php-fpm: pool www            
nobody    3907  3905  0 10:45 ?        00:00:00 php-fpm: pool www            
nobody    3908  3905  0 10:45 ?        00:00:00 php-fpm: pool www            
nobody    3909  3905  0 10:45 ?        00:00:00 php-fpm: pool www            
nobody    3910  3905  0 10:45 ?        00:00:00 php-fpm: pool www

To install modules on this build of php only
to install memcached extension to this new build of php 5.3

sudo yum install libmemcached-devel

download the memcache pecl source code using the pecl you just created in the 5.3 install

$ sudo ./bin/pecl download memcached

this will download an archive. decompress it and change into the source directory then

$ phpize
$ ./configure --with-php-config=/usr/local/php5.3/bin/php-config

This ensures the extension is written to the correct directory

make

the output of which should include

Libraries have been installed in:
  /usr/local/php5.3/memcached-1.0.2/modules

then install

sudo make install

The output should write to the correct installation

[steev@steev-desktop memcached-1.0.2]$ sudo make install
Installing shared extensions:     /usr/local/php5.3/lib/php/extensions/no-debug-non-zts-20090626/

If when booting php5.3 you get an error like this

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcached.so' - /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcached.so: cannot open shared object file: No such file or directory in Unknown on line 0

Then it is trying to load the module from the default location of /usr/local/lib when it needs to use /usr/local/php5.3/lib. The easy way is to create a file /etc/php5.3/nginx/conf.d/extension_dir and add this line

extension_dir=/usr/local/php5.3/lib/php/extensions/no-debug-non-zts-20090626/

Which will make php5.3 search for the memcache module, and any further modules, in the correct place.
APC

$ sudo pecl download apc
$ tar -xzf APC-3.1.9.tgz
$ cd APC-3.1.9
$ phpize
$  ./configure --with-php-config=/usr/local/php5.3/bin/php-config
$ make
$ sudo make install

Xdebug
Download the source code http://xdebug.org/files/xdebug-2.1.2.tgz and follow the instructions for APC. Ignore any instructions telling you to add extension=xdebug.so to any ini files. This will apparently cause problems. Do add this to /etc/php5.3/nginx/conf.d/xdebug.ini

zend_extension = /usr/local/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.remote_enable = on
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9000

Once you restart the php-fpm daemon you should be able to point Netbeans at local or remote machine and get a debug session on the go.

Add new comment