Skip to content

Instantly share code, notes, and snippets.

@petarov
Created March 22, 2015 13:44
Show Gist options
  • Save petarov/92a43303aaaa97174378 to your computer and use it in GitHub Desktop.
Save petarov/92a43303aaaa97174378 to your computer and use it in GitHub Desktop.
Multiple PHP versions on Archlinux

This describes the steps required to configure multiple PHP versions on your development system, if you have issue using the AUR package. Normally one may install the AUR package on a custom path, .e.g, /usr/local/php, but if you are like me having some issues with that you might want to try a custom compile.

Pay attention to step 6) as this is where any required extensions are enabled. For this setup we generally need pdo and mysql extensions.


  1. Download PHP version 5.3.13 (or any version that you are interested in) from http://php.net/releases/

  2. Download the php53 AUR package from https://aur.archlinux.org/packages/php53/

  3. Apply patches from the AUR package to the downloaded PHP sources in step 1). Use all the .patch files.

patch -p1 -i ./freetype-path.patch
patch -p0 -i ./php.ini.patch
patch -p0 -i ./php-fpm.conf.in.patch
patch -F3 -p1 -i ./suhosin.patch
  1. Apply node.c DOM error patch from here.
    curl -s https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt | patch -p0
  1. Use custom configuration:
./configure \
--prefix=/usr/local/php/php5.3.13 \
--with-zlib-dir \
--with-freetype-dir=shared,/usr \
--enable-mbstring \
--enable-soap \
--enable-calendar \
--with-curl \
--with-mcrypt \
--with-zlib \
--with-gd \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--enable-gd-native-ttf \
--enable-ftp \
--with-gettext \
--enable-xml \
--with-xmlrpc=shared \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-mysql=shared,mysqlnd \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-pdo-pgsql=shared \
--with-pdo-sqlite=shared,/usr \
--with-pgsql=shared

Add the following for SSL support, but be advised that you most likely need openssl v0.9.8 or so.

--with-openssl \

Add the following for FPM support:

--enable-fpm \
--with-fpm-user=http \
--with-fpm-group=http
  1. Compile & Install
make && make install
  1. Use php53-apache package from AUR to setup Apache's httpd.conf.

The way this works is to copy the libphp5.so and php5_module.conf to some dir, e.g., /usr/local/php/php-5.3.x/httpd and configure the path to these two files in /etc/httpd/conf/httpd.conf.

  1. Copy php.ini-development to /usr/local/php/php-5.3.x/bin and edit the settings.

Setup the extesion_dir path, .e.g.,

extension_dir = /usr/local/php/php5.3.13/lib/php/extensions/no-debug-non-zts-20090626/
  1. Restart the Apache server

  2. (Optional) Make a link to the php executable, e.g.,

ln -s /usr/bin/php5.3 `/usr/local/php/php-5.3.x/bin/php`
php5.3 --version

PHP 5.3.13 (cli) (built: ) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment