Install PHP 5.4 as standalone

PHP 5.4 is not packaged on most Linux distributions so it may be easiest to install it from source. On Debian-based Linux systems, you can use the following commands to install PHP 5.4 in such a way that it won’t effect any other versions of PHP that you may have installed:

  sudo apt-get install gcc libmysqlclient-dev libxml2-dev
  wget --trust-server-names http://us2.php.net/get/php-5.4.24.tar.bz2/from/us1.php.net/mirror
  tar xjf php-5.4.24.tar.bz2
  cd php-5.4.24
  ./configure --prefix=$PWD/installdir --enable-bcmath --with-mysql
  make install
  cd -

additionaly

--with-mysqli=mysqlnd --with-pdo-mysql=mysqlndphp-cgi

the binary used by the PHP SDK can be found in

php-5.4.24/installdir/bin/php-cgi

.

You can switch to the following folder, for the best pracice

/opt/php-5.4.24/installdir/bin/php-cgi

Then add to apache config file (/etc/apache2/http.conf)

ScriptAlias /php54-cgi /opt/php-5.4.24/installdir/bin/php-cgi/
Action application/x-httpd-php54 /php54-cgi

In desired virtual machine,

<VirtualHost>
...
  <FilesMatch "\.php">
    SetHandler application/x-httpd-php54
  </FilesMatch>
</VirtualHost>

Sources:
https://developers.google.com/appengine/docs/php/gettingstarted/installinglinux#PHP
http://stackoverflow.com/questions/15296103/how-to-install-php-5-4-without-overwriting-existing-older-php-version

5 thoughts on “Install PHP 5.4 as standalone”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.