Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to have two versions of PHP on one server and switch between them using a symlink.

I have PHP 5.3.2 installed. I want to install PHP 1.4.6 along side it and be able to switch back and forth between them eg;

/opt/php/live -> /opt/php/5.4.21

as suggested here. However I'm struggling to find out how to do this.

I'm using an Ubuntu 10.04 server running Nginx and PHP-FPM/FastCGI.

To my mind apt-get seems to want to only have one version of each program so I guess having two versions side-by-side must avoid using apt-get or similar utils.

share|improve this question
Not tested yet, but you should be able to specify the php.ini file in nginx.conf. – matrixdevuk Mar 18 '14 at 2:04
I don't think you can specify the php.ini file in nginx.conf. Nginx passes the HTTP request to PHP using FastCGI ie. ip/port eg. fastcgi_pass To Nginx, PHP is just another server. – Nigel Alderton Mar 18 '14 at 2:20
Then setup a few of those, and pass them over. :) – matrixdevuk Mar 18 '14 at 2:29

You'll have to compile it yourself. To get a compilation that is very close to the precompiled Ubuntu you can use the same config flags as in the Ubuntu source package but with a different --prefix:

    ./configure \
        --prefix=/opt/php/5.3.2 \
        --enable-force-cgi-redirect \
        --enable-fastcgi \
        --disable-debug \
        --with-regex=php \
        --disable-rpath \
        --disable-static \
        --with-pic \
        --with-layout=GNU \
        --with-pear=/usr/share/php \
        --enable-calendar \
        --enable-sysvsem \
        --enable-sysvshm \
        --enable-sysvmsg \
        --enable-bcmath \
        --with-bz2 \
        --enable-ctype \
        --with-db4 \
        --without-gdbm \
        --with-iconv \
        --enable-exif \
        --enable-ftp \
        --with-gettext \
        --enable-mbstring \
        --with-pcre-regex=/usr \
        --enable-shmop \
        --enable-sockets \
        --enable-wddx \
        --with-libxml-dir=/usr \
        --with-zlib \
        --with-kerberos=/usr \
        --with-openssl=/usr \
        --enable-soap \
        --enable-zip \
        --with-mhash=yes \
        --with-system-tzdata \
        --without-mm \
        --with-curl=/usr \
        --with-enchant=/usr \
        --with-zlib-dir=/usr \
        --with-gd=/usr --enable-gd-native-ttf \
        --with-gmp=/usr \
        --with-jpeg-dir=/usr \
        --with-xpm-dir=/usr/X11R6 \
        --with-png-dir=/usr \
        --with-freetype-dir=/usr \
        --enable-intl \
        --with-ttf=/usr \
        --with-t1lib=/usr \
        --with-ldap=/usr \
        --with-ldap-sasl=/usr \
        --with-mysql=/usr \
        --with-mysqli=/usr/bin/mysql_config \
        --with-pspell=/usr \
        --with-unixODBC=/usr \
        --with-recode=/usr \
        --with-xsl=/usr \
        --with-snmp=/usr \
        --with-sqlite=/usr \
        --with-sqlite3=/usr \
        --with-mssql=/usr \
        --with-tidy=/usr \
        --with-xmlrpc \
        --with-pgsql=/usr PGSQL_INCLUDE=`pg_config --includedir` \
        --enable-pdo \
        --without-pdo-dblib \
        --with-pdo-mysql=/usr \
        --with-pdo-odbc=unixODBC,/usr \
        --with-pdo-pgsql=/usr/bin/pg_config \
        --with-pdo-sqlite=/usr \

Of course, any of those modules you don't need can be removed from the configure (e.g. if you are never going to use snmp then change --with-snmp=/usr to --without-snmp or just leave it out altogether)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.