6

I am attempting to install PHP 5.6 on Ubuntu 14.04. I have tried a whole raft of different things and none of them work. To start with I have tried to download via this repo:

sudo add-apt-repository ppa:ondrej/php5-5.6

Followed by:

sudo apt install php5

As most of the Google results I can find tell me to do, but when I check php -v I find I am still on 5.9.9, which is no use for what I need.

I have also tried:

sudo apt install php5.6

As I have seen listed elsewhere, but I just get a message saying the repository does not exist.

I have also tried installing using this repository:

sudo add-apt-repository ppa:ondrej/php5

As listed in this question: PHP 5.6 not used by Apache instead it uses PHP 5.5

But the repository doesn't appear to exist any more.

I have also tried installing PHP 5.6.10 and 5.6.12 from tarballs, but I can't seem to get the installation instructions contained within the tarballs to work, and running either make or make install from within the directory that contains Makefile.frag, Makefile.gov etc does nothing.

Is there another way to install the required version of PHP, or can anyone perhaps give me instructions on how to install either of the above tarballs now I have unzipped and untarred them? I found a guide suggesting to find the 'dbase' folder but this does not appear to exist with these particular versions of PHP.

I have also tried installing PHP 7.0 but have found this doesn't work with the Laravel repository I need to work with (I have also tried using Vagrant Homestead to install the right version of PHP, but this has produced other issues on my system).

I have attempted to run

./configure
make
make install

In the root directory the tarball has untarred to, but although the ./configure seems to work fine, when I run make I see:

make: *** No targets specified and no makefile found. Stop.

I have already tried running:

sudo apt-get install libapache2-mod-php5.6

As per the answer to the linked to similar question marked as possible duplicate of mine. Which results in this output:

Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package libapache2-mod-php5.6 E: Couldn't find any package by regex 'libapache2-mod-php5.6'"

Even after adding this repository:

sudo add-apt-repository ppa:ondrej/apache2
1
  • Comments are not for extended discussion; the entire conversation taking place here has been moved to chat.
    – Thomas Ward
    Dec 29, 2016 at 16:57

1 Answer 1

3

Since your looking for an older php version you will need to compile it yourself, and here are the steps:

  1. Remove all installed php versions:
    • use:
      • sudo add-apt-repository -r repository_name
      • sudo apt update
      • sudo apt dist-upgrade
  2. Download the version you want from here
  3. To avoid compilation errors install dependencies:

    apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-dbg libmcrypt-dev libssl-dev libbz2-dev libjpeg-dev \
    libfreetype6-dev libpng12-dev libxpm-dev libxml2-dev libpcre3-dev  libbz2-dev libcurl4-openssl-dev \
    libjpeg-dev libpng12-dev libxpm-dev libfreetype6-dev libmysqlclient-dev libt1-dev libgd2-xpm-dev \
    libgmp-dev libsasl2-dev libmhash-dev unixodbc-dev freetds-dev libpspell-dev libsnmp-dev libtidy-dev \
    libxslt1-dev libmcrypt-dev libdb5.3-dev
    
  4. Create a directory for building:

    • mkdir -p /opt/build
  5. Extract the download to the created directory:
    • tar -xvjpf /path/to/download/location -C /opt/build
  6. Move into folder:
    • cd /opt/build/
  7. Now configure it to suit your needs, here is an example configuration:

    ./configure \
    --enable-fpm \
    --with-mcrypt \
    --enable-mbstring \
    --with-openssl \
    --with-mysql \
    --with-mysql-sock \
    --with-gd \
    --with-jpeg-dir=/usr/lib \
    --enable-gd-native-ttf  \
    --with-pdo-mysql \
    --with-libxml-dir=/usr/lib \
    --with-mysqli=/usr/bin/mysql_config \
    --with-curl \
    --enable-zip  \
    --enable-sockets \
    --with-zlib \
    --enable-exif \
    --enable-ftp \
    --with-iconv \
    --with-gettext \
    --enable-gd-native-ttf \
    --with-t1lib=/usr \
    --with-freetype-dir=/usr \
    --prefix=/opt/PHP-5.6 \
    --with-config-file-path=/opt/PHP-5.6/etc \
    --with-fpm-user=www-data \
    --with-fpm-group=www-data
    
  8. Run the following commands:

    • make
    • make test
  9. Then install if all goes well:

    • make install
  10. Confirm install:

    • /opt/PHP-5.6/bin/php -v
  11. Add the php location to your .bashrc file:

    • export PATH=/opt/PHP-5.6/bin:$PATH

Note:

You will have to manually update your php install when you need to. -

Not the answer you're looking for? Browse other questions tagged .