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
  tar xjf php-5.4.24.tar.bz2
  cd php-5.4.24
  ./configure --prefix=$PWD/installdir --enable-bcmath --with-mysql
  make install
  cd -


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

the binary used by the PHP SDK can be found in



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


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,

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


This entry was posted in Hosting, Linux and tagged , . Bookmark the permalink.

5 Responses to Install PHP 5.4 as standalone

  1. Dragoslav says:

    I 5.3 je sasvim dovoljan ..

Leave a Reply

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