Last active
December 17, 2015 15:54
-
-
Save davidbehan/9061023 to your computer and use it in GitHub Desktop.
Script for installing multiple php versions in plesk 11.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FROM: http://forum.parallels.com/showthread.php?290399-Plesk-11-5-Easy-Install-Script-for-Multiple-PHP-CentOS-6-4-x64 | |
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 --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" | |
phpconfigureflagsspecific[5.4.25-cgi]="--without-sqlite3 --without-pdo_sqlite3 --enable-intl" | |
phpconfigureflagsspecific[5.5.9-cgi]="--without-sqlite3 --without-pdo_sqlite3 --enable-intl" | |
phpconfigureflagsspecific[5.3.27-fpm]="--enable-fpm --without-sqlite3 --enable-intl" | |
phpconfigureflagsspecific[5.4.25-fpm]="--enable-fpm --without-sqlite3 --without-pdo_sqlite3 --enable-intl" | |
phpconfigureflagsspecific[5.5.9-fpm]="--enable-fpm --without-sqlite3 --without-pdo_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" | |
phpdownloadurl[5.4.25-cgi]="http://ie2.php.net/get/php-5.4.25.tar.gz/from/this/mirror" | |
phpdownloadurl[5.5.9-cgi]="http://ie2.php.net/get/php-5.5.9.tar.gz/from/this/mirror" | |
phpdownloadurl[5.3.27-fpm]="${phpdownloadurl[5.3.27-cgi]}" | |
phpdownloadurl[5.4.25-fpm]="${phpdownloadurl[5.4.25-cgi]}" | |
phpdownloadurl[5.5.9-fpm]="${phpdownloadurl[5.5.9-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 | |
install_php 5.4.25 cgi | |
install_php 5.5.9 cgi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Beautiful. I only needed the PHP5.5 parts of this - worked without a hitch on Plesk 11.5/CentOS. It did not even need a reboot or restart of Plesk.
Edit: However, I'm getting "SQLSTATE[HY000] [2002] No such file or directory" trying to connect to MySQL using PDO. Changing the host from "localhost" to "127.0.0.1" bizarrely fixed that. "localhost" works for all other PHP versions and scripts, so why this version of PHP does not look into the hosts file, is a mystery.