Thursday, February 11, 2016

PHP 5.6 on CentOS 5.9 with Apache Mod FCGI

PHP5.6 on CentOS 5.9 with Apache Mod FCGI

# http://crybit.com/20-common-php-compilation-errors-and-fix-unix/
# https://coderwall.com/p/ggmpfa/php-configuration-error-and-solutions-in-rpm

mkdir /opt/php-5.6.18
mkdir -p /usr/local/src/php-5.6.18
cd /usr/local/src/php-5.6.18
wget http://de.php.net/get/php-5.6.18.tar.bz2/from/this/mirror -O php-5.6.18.tar.bz2
tar jxf php-5.6.0.tar.bz2

yum install bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libc-client-devel.i686 libc-client-devel libmcrypt-devel -y
yum install libxml2-devel bzip2-devel libcurl-devel libpng-devel db4-devel postgresql-devel sqlite-devel aspell-devel net-snmp-devel libxslt-devel libxml2-devel pcre-devel t1lib-devel.x86_64 libmcrypt-devel.x86_64 libtidy libtidy-devel curl-devel libjpeg-devel libvpx-devel freetype-devel libc-client-devel -y

./configure --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-imap --with-imap-ssl --with-kerberos --enable-mbstring --with-mcrypt --with-mhash --with-mysql --with-mysqli --enable-mysqlnd --with-openssl --with-pcre-regex --with-pdo-mysql --with-zlib-dir --with-regex --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-soap --enable-sockets --with-xmlrpc --enable-zip --with-zlib --enable-inline-optimization --enable-mbregex --enable-opcache --enable-fpm --prefix=/usr/local/php --with-xpm-dir=/usr --with-vpx-dir=/usr
make
make install

# Fast CGI
sudo rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
sudo rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
sudo yum install mod_fastcgi

# Disable mod php5
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disable

# Create a script in /var/www/cgi-bin/php.fcgi

#!/bin/bash
# Shell Script To Run PHP5 using mod_fastcgi under Apache 2.x
# Tested under Red Hat Enterprise Linux / CentOS 5.x
### Set PATH ###
----------------------------
PHP_CGI=/usr/bin/php-cgi
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000
### no editing below ###
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec $PHP_CGI
----------------------------
# Make executable
chmod +x /var/www/cgi-bin/php.fcgi

# Add the handler in your apache vhost or directory config

        Options +Indexes -IncludesNOExec
        AllowOverride All
        AddHandler php5-fastcgi .php
        DirectoryIndex index.php index.html
        Order deny,allow
        Allow from all
        AddType text/html .php
        Action php5-fastcgi /cgi-bin/php.fcgi


# Alias is great for sharing subdirectories on a single host e.g. host/www1, host/www2
Alias /callcenter /var/www/html/app

# Or a virtual host
#NameVirtualHost 127.0.0.1

#
#    ServerName demo.chickenkiller.com
#    ServerAdmin webmaster@localhost
#    DocumentRoot "/var/www/html/callcenter"
#    LogLevel debug
#    ErrorLog logs/callcenter-error.log
#    CustomLog logs/callcenter-access.log combined
#