Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install PHP 5.5.23 on Plesk 11.5 and 12 (CentOS 6)
# Make sure you are up to date
yum -y update && yum -y install wget
# Install EPEL repository
rpm -ivh
# Get us a clean working directory
mkdir /php
cd /php
# Install PHP dependencies
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 libtool-ltdl-devel
# Download PHP
wget -O /php/php-5.5.23.tar.gz
# Extract PHP
tar xzvf /php/php-5.5.23.tar.gz
# Move to unpacked folder
cd /php/php-5.5.23
# Configure PHP build script
./configure \
--with-libdir=lib64 \
--cache-file=./config.cache \
--prefix=/php/php-5.5.23 \
--with-config-file-path=/php/php-5.5.23/etc \
--disable-debug \
--with-pic \
--disable-rpath \
--with-bz2 \
--with-curl \
--with-freetype-dir=/php/php-5.5.23 \
--with-png-dir=/php/php-5.5.23 \
--enable-gd-native-ttf \
--without-gdbm \
--with-gettext \
--with-gmp \
--with-iconv \
--with-jpeg-dir=/php/php-5.5.23 \
--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=/php/php-5.5.23 \
--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-pear=/php/php-5.5.23/pear \
--with-mcrypt \
--without-pdo-sqlite \
--with-config-file-scan-dir=/php/php-5.5.23/php.d \
--without-sqlite3 \
--enable-intl \
# Build & Install
make && make install
# Create a default php.ini
mkdir /php/php-5.5.23/etc
cp -a /etc/php.ini /php/php-5.5.23/etc/php.ini
# Set the timezone
timezone=$(grep -oP '(?<=")\w+/\w+' /etc/sysconfig/clock)
sed -i "s#;date.timezone =#date.timezone = $timezone#" /php/php-5.5.23/etc/php.ini
# Register with Plesk
/usr/local/psa/bin/php_handler \
--add \
-displayname "5.5.23" \
-path /php/php-5.5.23/bin/php-cgi \
-phpini /php/php-5.5.23/etc/php.ini \
-type fastcgi \
-id "fastcgi-5.5.23"
Copy link

alsuufi commented Oct 6, 2014

Thank you so much it worked

Copy link

computerworxdev commented Nov 15, 2014

Thank you that worked for me too
is there a way to get Instructions for 5.5.18 ?


Copy link

thiagodebastos commented Dec 14, 2014

The only thing that failed for me was

timezone=$(grep -oP '(?<=")\w+/\w+' /etc/sysconfig/clock)

The clock folder does not exist. I'm on Plesk 12, CentOS 6

Copy link

stayallive commented Dec 18, 2014

@computerworxdev: Replace all occurrences of the version with the version you desire and you should be good to go!

@thiago-om: When you run grep -oP '(?<=")\w+/\w+' /etc/sysconfig/clock in the terminal it should display the current timezone, cannot see why this would be missing...

Copy link

gdhnz commented Jan 1, 2015

I'm also missing /etc/sysconfig/clock but using the following returned the correct timezone for me

timezone=$(readlink /etc/localtime | sed "s/\/usr\/share\/zoneinfo\///")

Copy link

atrandafir commented Feb 2, 2015

Hey I used this script to install php 5.6.5 on my Centos 6.5 dedicated server that is running Plesk12 and then switched the php version from plesk just for one of my websites to test it, and it gave me this error: SQLSTATE[HY000] [2002] No such file or directory

Looks like for some reason it cannot connect to mysql. I'm using "localhost" as the host. I found some info regarding setting pdo_mysql.default_socket in php.ini but for some reason it doesn't let me set it, keeps using the default value.

Now I'm also wondering, when installing with your script what happens to php extensions? I can see almost no .so files in the extensions directory of this php installation, just the one for opcache, but none for pdo_mysql and so on, even so, the extensions are loaded somehow but I don't know from where.

In case of the original Plesk php installation that uses the /etc/php.ini and /etc/php.d/ for additional inis I can see it loads the extensions, by the php.ini, and additional inis. So, how does it load the extensions? By the configuration command instead of the inis?

Update to my issue above:
The error went away after configuring again specifying the path of the mysql socket:
--with-mysql-sock=/var/lib/mysql/mysql.sock (in my case)
and then:
make clean
make && make install

Copy link

md-frg commented Feb 5, 2015


I am getting error that PHP handler can not be registered, because of missing Directory /php/php-5.5.20/bin/php-cgi

Copy link

atrandafir commented Feb 8, 2015

@md-frg are you sure the installation was completed? maybe you've got some compilation error, also make sure all the paths in the script are correct in case you've changed them

Copy link

lebnene commented Feb 28, 2015

I am getting the following error, any hints? Thanks.

[2015-02-28 03:10:32] ERR [util_exec] proc_close() failed
Unable to register the PHP handler: Binary /php/php-5.5.20/bin/php-cgi doesn't exists

Copy link

bartdenhoed commented Mar 21, 2015

No errors but it still has php 5.4 en not 5.5....... Why?

Copy link

rubenve commented May 29, 2015

You still have to enable it for a website. You can do this in Websites > Hosting Settings for a specific website.
This procedure just compiles and installs the custom handler.

Copy link

filpgame commented Jul 3, 2015

and how to register for Apache module?

Copy link

frenci8 commented Aug 3, 2015

Hero! Worked perfectly

Copy link

leechilli commented Oct 30, 2015

Thanks for this, I've installed this but can't seem to enable opcache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment