The following script I made will automate these tasks:
- Install needed dependencies
- Download and extract sources
- Configure and make sources
- Install and register new PHP
- You will then be able to find the new PHP version in Plesk -> Domain -> Websites & Domains -> Web Hosting Access -> PHP -> FastCGI
Code:
yum -y install gcc make gcc-c++ cpp kernel-headers.x86_64 libxml2-devel openssl-devel bzip2-devel libjpeg-devel libpng-devel freetype-devel openldap-devel postgresql-devel aspell-devel net-snmp-devel libxslt-devel libc-client-devel libicu-devel gmp-devel curl-devel libmcrypt-devel unixODBC-devel pcre-devel sqlite-devel db4-devel enchant-devel libXpm-devel mysql-devel readline-devel libedit-devel recode-devel libtidy-devel
phpconfigureflagscommon="--with-libdir=lib64 --cache-file=./config.cache --prefix=/usr/local/php-\$phpversion-\$phptype --with-config-file-path=/usr/local/php-\$phpversion-\$phptype/etc --disable-debug --with-pic --disable-rpath --with-bz2 --with-curl --with-freetype-dir=/usr/local/php-\$phpversion-\$phptype --with-png-dir=/usr/local/php-\$phpversion-\$phptype --enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr/local/php-\$phpversion-\$phptype --with-openssl --with-pspell --with-pcre-regex --with-zlib --enable-exif --enable-ftp --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-wddx --with-kerberos --with-unixODBC=/usr --enable-shmop --enable-calendar --with-libxml-dir=/usr/local/php-\$phpversion-\$phptype --enable-pcntl --with-imap --with-imap-ssl --enable-mbstring --enable-mbregex --with-gd --enable-bcmath --with-xmlrpc --with-ldap --with-ldap-sasl --with-mysql=/usr --with-mysqli --with-snmp --enable-soap --with-xsl --enable-xmlreader --enable-xmlwriter --enable-pdo --with-pdo-mysql --with-pdo-pgsql --with-pear=/usr/local/php-\$phpversion-\$phptype/pear --with-mcrypt --without-pdo-sqlite --with-config-file-scan-dir=/usr/local/php-\$phpversion-\$phptype/php.d"
declare -A phpconfigureflagsspecific
phpconfigureflagsspecific[5.2.17-cgi]="--enable-fastcgi"
phpconfigureflagsspecific[5.3.27-cgi]="--without-sqlite3 --enable-intl" [COLOR="#FF0000"]DELETE THIS LINE?[/COLOR]
phpconfigureflagsspecific[5.4.17-cgi]="--without-sqlite3 --enable-intl"
phpconfigureflagsspecific[5.5.1-cgi]="--without-sqlite3 --enable-intl"
phpconfigureflagsspecific[5.3.27-fpm]="--enable-fpm --without-sqlite3 --enable-intl" [B][COLOR="#FF0000"]DELETE THIS LINE[/COLOR][/B]
phpconfigureflagsspecific[5.4.17-fpm]="--enable-fpm --without-sqlite3 --enable-intl"
phpconfigureflagsspecific[5.5.1-fpm]="--enable-fpm --without-sqlite3 --enable-intl"
declare -A phpdownloadurl
phpdownloadurl[5.2.17-cgi]="http://museum.php.net/php5/php-5.2.17.tar.gz"
phpdownloadurl[5.3.27-cgi]="http://be2.php.net/get/php-5.3.27.tar.gz/from/this/mirror" [COLOR="#FF0000"]DELETE THIS LINE?[/COLOR]
phpdownloadurl[5.4.17-cgi]="http://be2.php.net/get/php-5.4.17.tar.gz/from/this/mirror"
phpdownloadurl[5.5.1-cgi]="http://be2.php.net/get/php-5.5.1.tar.gz/from/this/mirror"
phpdownloadurl[5.3.27-fpm]="${phpdownloadurl[5.3.27-cgi]}" [COLOR="#FF0000"]DELETE THIS LINE?[/COLOR]
phpdownloadurl[5.4.17-fpm]="${phpdownloadurl[5.4.17-cgi]}"
phpdownloadurl[5.5.1-fpm]="${phpdownloadurl[5.5.1-cgi]}"
install_php () {
cd /usr/local/src/
phpversion=$1
phptype=$2
[[ -z "$2" ]] && echo "Usage: install_php phpversion phptype" && return 1
wget ${phpdownloadurl[$phpversion-$phptype]} -O /usr/local/src/php-$phpversion-$phptype.tar.gz
mkdir /usr/local/src/php-$phpversion-$phptype/
tar xzvf /usr/local/src/php-$phpversion-$phptype.tar.gz -C /usr/local/src/php-$phpversion-$phptype/ --strip 1
cd /usr/local/src/php-$phpversion-$phptype/
eval ./configure $phpconfigureflagscommon ${phpconfigureflagsspecific[$phpversion-$phptype]}
make -j $(grep processor /proc/cpuinfo | wc -l)
[ ! -d "/usr/local/php-$phpversion-$phptype/" ] && make install
# These ifs need a rewrite, CentOS 5.9 still ships PHP 5.2.10 as default and so /etc/php.ini will not work for PHP 5.3+ #
if [ "$phpversion" == "5.2.17" ]
then
cp /usr/local/src/php-$phpversion-$phptype/php.ini-recommended /usr/local/php-$phpversion-$phptype/etc/php.ini
sed -i "s#;date.timezone =#date.timezone = $timezone#" /usr/local/php-$phpversion-$phptype/etc/php.ini
else
cp -a /etc/php.ini /usr/local/php-$phpversion-$phptype/etc/php.ini
fi
[ "$phptype" == "cgi" ] && /usr/local/psa/bin/php_handler --add -displayname "$phpversion" -path "/usr/local/php-$phpversion-$phptype/bin/php-cgi" -phpini "/usr/local/php-$phpversion-$phptype/etc/php.ini" -type fastcgi -id "fastcgi-$phpversion"
[ "$phptype" == "fpm" ] && /usr/local/psa/bin/php_handler --add -displayname "$phpversion-$phptype" -path "/usr/local/php-$phpversion-$phptype/bin/php-cgi" -phpini "/usr/local/php-$phpversion-$phptype/etc/php.ini" -type fastcgi -id "fpm-$phpversion"
}
install_php 5.2.17 cgi
install_php 5.3.27 cgi [COLOR="#FF0000"]DELETE THIS LINE?[/COLOR]
install_php 5.4.17 cgi
install_php 5.5.1 cgi
Note that this version of the script does NOT work with CentOS 5.9 (declare -A is not available in bash 3).
PHP 5.5.1 will also not compile on CentOS 5.9 because of old dependencies.
An updated guide and full PHP-FPM support will be made available on
http://www.stone-is.com/en/blog/hos...-php-versions-for-plesk-115-centos-64-x64/29/
If enough requests make it, I will create an alternate version for CentOS 5.9