How to install PHP (5.5.15) from source (...and use it with Plesk 12)
This will work both for CentOS, Debian, and Ubuntu. Just use a different package manger depending on distro.
Find your mirror (http://php.net/downloads.php), and download the latest PHP verison eg. 5.5.15 for me. I save to a tarball called php.tar.gz:
$ curl -L http://dk1.php.net/get/php-5.5.15.tar.gz/from/this/mirror -o php.tar.gz
Extract the tarball:
$ tar -xzvf php.tar.gz
Change directory to the directory with the PHP source:
$ cd php-5.5.15/
Install dependencies - if you configure, and you are missing dependencies it will take forever to ./configure, and install dependency, ./configure and install dependency, and etc. etc., so just run this piece (Debian in this case). I install these because i know that they are good to have in PHP, and i know my Plesk 12 installation depend on them:
$ apt-get install gcc openssl-devel bzip2-devel curl-devel libpng-devel libc-client-devel re2c libxml2-devel libevent-devel zlib1g-devel libbz2-devel gmp-devel libssl-devel libcurl4-openssl-devel openssl-devel openssl-dev libjpeg-devel libpng-devel libxpm-devel libgd2-xpm-devel libmcrypt-devel libpcre3-devel libc-client-devel libkrb5-devel libsasl2-devel libmysqlclient-devel libpspell-devel libsnmp-devel libtidy-devel libxslt-devel libtool libxml2-devel libvpx-devel freetype-devel libicu-devel net-snmp-devel -y
Configure PHP, and add it to directory /usr/local/php5515:
$ ./configure --disable-debug --disable-rpath --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-fpm --enable-gd-native-ttf --enable-intl --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-pdo --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-xmlreader --enable-xmlwriter --enable-zip --prefix=/usr/local/php5515 --with-bz2 --with-config-file-path=/usr/local/php5515/etc --with-config-file-scan-dir=/usr/local/php5515/php.d --with-curl --with-freetype-dir=/usr/local/php5515 --with-gd --with-gettext --with-gmp --with-iconv --with-imap --with-imap-ssl --with-xpm-dir=/usr/local/php5515 --with-vpx-dir=/usr/local/php5515 --with-kerberos --with-libdir=lib64 --with-libxml-dir=/usr/local/php5515 --with-mcrypt --with-openssl --with-pcre-regex --with-pdo-mysql --with-pic --with-png-dir=/usr/local/php5515 --with-snmp --with-xmlrpc --with-xsl --with-zlib --without-gdbm --with-mysqli
If you do not care about any modules, and just want a clean PHP installation (probably need to configure modules later on then), just configure it as simple as possible:
$ ./configure
Make, make (build) test it, before installation:
$ make; make test
If everything is OK, install it:
$ make install
When done, copy the dummy php.ini-production file from the directory to the directory with our PHP 5.5.15 installation, and call it just php.ini:
$ cp php.ini-production /usr/local/php5514/etc/php.ini
If you want to have other php configuration files, create this directory:
$ mkdir /usr/local/php5515/php.d/
You are done! :-)
I create a configuration file (.ini) for plesk, called plesk.ini, and added it to /usr/local/php5515/php.d/, because i needed one like that:
post_max_size = 32M
upload_max_filesize = 32M zend_extension=/usr/local/php5515/lib/php/extensions/no-debug-non-zts-20121212/opcache.so
opcache.memory_consumption=64
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=2001
opcache.revalidate_freq=5
opcache.fast_shutdown=1
opcache.enable_cli=0
opcache.enable=1
I configure some OPcache options here. If you do not know what this is, read more in the PHP docs: "OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request." - http://php.net/manual/en/intro.opcache.php
Plesk
In my case, i needed to add it to Plesk for a customer, and that is done with a line like the following:
$ /usr/local/psa/bin/php_handler --add -displayname 5.5.15 -path /usr/local/php5515/bin/php-cgi -phpini /usr/local/php5515/etc/php.ini -type fastcgi -id php5515
Go to your Plesk panel under Hosting Settings, and set your PHP choice to FastCGI + PHP 5.5.15. Create a php file with the following content to check your php information from the server:
<?php
phpinfo();
?>
Now if you put your info.php file to your root dir, at eg. http://localhost/info.php you should see this in the top of the page: