4

ppa:ondrej/php5-oldstable does not support PHP 5.4 for Ubuntu 13.10 and higher. There seems to be no official or a stable way to install PHP 5.4 instead of 5.5 on Ubuntu 14.04 LTS currently. I've seen most answers on StackOverflow/Exchange but in the end, they are mostly all outdated.

How can I install PHP 5.4 on Ubuntu 14.04 LTS directly from a repository?

3 Answers3

12

Install requirements for phpbrew

apt-get update
apt-get upgrade
apt-get build-dep php5
apt-get install -y php5 php5-dev php-pear autoconf automake curl build-essential libxslt1-dev re2c libxml2 libxml2-dev php5-cli bison libbz2-dev libreadline-dev
apt-get install -y libfreetype6 libfreetype6-dev libpng12-0 libpng12-dev libjpeg-dev libjpeg8-dev libjpeg8  libgd-dev libgd3 libxpm4 libltdl7 libltdl-dev
apt-get install -y libssl-dev openssl
apt-get install -y gettext libgettextpo-dev libgettextpo0
apt-get install -y php5-cli
apt-get install -y libmcrypt-dev
apt-get install libicu-dev

Install phpbrew

curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod +x phpbrew
sudo mv phpbrew /usr/bin/phpbrew

Initialise phpbrew, update and install PHP 5.4

phpbrew init
phpbrew known --update
phpbrew update

Here we choose PHP 5.4.34, but you can change this to any version that is available as listed by the above commands - like 5.5.22.

phpbrew install 5.4.34 +default

Update your shell config file by adding the following to the end of your ~/.bashrc or ~/.zshrc (basically the shell you're using, default to .bashrc)

source ~/.phpbrew/bashrc

Close your terminal to take effect, and restart it.

Switch the default PHP version to 5.4

phpbrew switch php-5.4.34

If it shows Invalid Argument, try phpbrew switch 5.4.34 instead.

Check your PHP version

php -v
0

If it shows Invalid Argument, try over and over again nothing, the only thing that help is these two line and in this order:

source ~/.phpbrew/bashrc && phpbrew list
phpbrew switch 5.4.45
Mark Kirby
  • 18,949
  • 19
  • 79
  • 116
zvika
  • 1
0

Make sure phpbrew is located in:

/usr/local/bin

not

/usr/bin
techraf
  • 3,316