PHP 5.4 Configuration For Apache 2.4

PHP 5.4 InfoIn one of the systems we manage, we are running Apache httpd 2.4 with PHP and mod_fcgid.  We configure PHP 5.4 for compilation using this script:

#! /bin/sh
#
# Created by configure

'./configure' \
'--enable-intl' \
'--enable-cgi' \
'--enable-fpm' \
'--with-apxs2=/opt/apache/bin/apxs' \
'--with-fpm-user=daemon' \
'--with-fpm-group=daemon' \
'--with-pear' \
'--with-libdir=lib64' \
'--with-curl=shared' \
'--with-openssl=shared' \
'--prefix=/opt/php5' \
'--with-gdbm=shared' \
'--enable-dba=shared' \
'--with-db4=shared' \
'--enable-ftp' \
'--with-gd=shared' \
'--with-imap=shared' \
'--with-kerberos=/usr' \
'--with-imap-ssl=shared' \
'--enable-sockets' \
'--enable-zip' \
'--with-jpeg-dir=/usr' \
'--with-png-dir=/usr' \
'--with-xpm-dir=/usr' \
'--with-zlib' \
'--with-zlib-dir=/usr' \
'--with-bz2=shared' \
'--enable-exif' \
'--enable-soap' \
'--with-mcrypt=/usr/local' \
'--with-mhash' \
'--enable-mbstring' \
'--with-mysql=mysqlnd' \
'--with-mysqli=mysqlnd' \
'--with-pdo-mysql=mysqlnd' \
'--with-snmp=shared' \
'--enable-wddx' \
'--with-xmlrpc=shared' \
'--with-xsl=shared' \
'--with-ldap=shared' \
'--with-ldap-sasl' \
"$@"

The above configuration is valid as long as the requisite software and libraries are installed. For our CentOS system, we use yum (which uses rpm) to install these software and libraries.

After running the above script to configure the PHP source, we compile and install PHP:

make
make test
sudo make install

Note that our PHP configuration for compilation lets us generate a command-line PHP binary (php), a FastCGI PHP binary (php-cgi), a FastCGI Process Manager-enabled binary (php-fpm) and an Apache httpd 2 module (libphp5.so).

As for the existing Apache httpd 2.4 installation, we configure /etc/opt/apache/httpd.conf to make use of php-cgi through mod_fcgid:

# Make sure mod_fcgid is enabled above.
# libphp5.so must be disabled.
# PHP5.4 - FCGI
<IfModule fcgid_module>
    <FilesMatch \.php$>
        AddHandler fcgid-script .php
        Options +ExecCGI
        FcgidWrapper /opt/php5/bin/php-wrapper  .php
    </FilesMatch>
</IfModule>

Now, /opt/php5/bin/php-wrapper is simply this script:

#!/bin/bash

PHP_FCGI_MAX_REQUESTS=10000
export PHP_FCGI_MAX_REQUESTS

# Disable PHP child process management. Let mod_fcgid
# handle it
PHP_FCGI_CHILDREN=0
export PHP_FCGI_CHILDREN 

exec /opt/php5/bin/php-cgi $@

The above script is based on an example in http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#examples.

Be aware that, with the FilesMatch directive above, access controls applied to PHP files may get a bit tricky. Take note of the order of directives and refer to the Apache httpd 2.4 documentation for tips and for more information. See http://httpd.apache.org/docs/2.4/howto/access.html for example.

Happy Birthday, Linux!

We wish Linux a happy 20th birthday. Knowing that Linux is alive, well, and unbound, we celebrate this year with The Linux Foundation. Thanks to Linus Torvalds, computing has changed for the better.

It’s nice to know that we have an alternative operating system which has proven to be scalable, reliable, innovative and even fun!  We are pleased to see that Linux is welcome in organizations and business entities.  I wonder what more can we expect from Linux in the next decade.

The Linux ecosystem is very much alive and thriving.  A lot of companies are now building products and services on top of Linux.  Companies like IBM, Intel, HP, Oracle, etc. now have Linux as one of their platforms for building new products and services.  Many application domains are using Linux as a computing platform.  RedHat and Canonical have been built and are successful in the Linux ecosystem.

As for us users, we benefit from the Linux ecosystem because we have a good alternative to proprietary products and solutions.  Linux is technically sound and has been ready for various applications.

There is still room to grow.  Desktop Linux is slowly picking up but needs more momentum.  User-friendliness is improving with the use of desktop interfaces such as Gnome and KDE.  Video cards need more support and solutions from hardware vendors who make device drivers.

Well, it’s good to know that Linux has made it and that its future looks bright. Even Microsoft is beginning to notice.