How to Install an older version of php using apt-get?
Asked Answered
B

3

5

I have this older package in this exact version that I want to install on Ubuntu.

https://launchpad.net/ubuntu/+source/php5/5.3.10-1ubuntu3.20

How can I install it using apt-get ? Thank you

Bombacaceous answered 25/11, 2016 at 9:23 Comment(2)
without apt-get, you could just download it and use dpkg -iPickax
it depends on your Ubuntu version.Omphale
C
6

For those looking for an earlier version of php 7.

List all php 7 versions:

apt-cache policy php7.*

Specify and install a specific php 7 version, in example 7.4.3:

sudo apt install php7.4-fpm=7.4.3-4ubuntu2.2
                          ^ ^
                          | |
            (left) pkgname / (right) version part 
Cooe answered 7/7, 2020 at 22:2 Comment(1)
Thank you! I installed php7.2 => sudo apt install php7.2=7.2.24-0ubuntu0.18.04.8Camphor
A
3

to find out what different versions of a package is available in the enabled repository

apt-cache policy <package-name>

in your case

apt-cache policy php5

select the version that you want to install and then type

sudo apt-get install pkgname=version

in your case

sudo apt-get install php5=5.3.10-1ubuntu3.20

before running any of the above commands, it is better to update the apt-cache first. To do it, run

sudo apt-get update
Abstractionism answered 25/11, 2016 at 12:16 Comment(4)
apt-cache policy php5 finds me only 5.5.9+dfsg-1ubuntu4.20 0 packageBombacaceous
@MariánZekeŠedaj it means that it is the only version of php5 available in your enabled repository. You might need to add new repository to be able to install other versions. or, as karsten suggested, you can download .deb files and manually and install them using dpkg -i <filename> However, there are chances that other version might not be supported on your ubuntu version. By the way, what version of Ubuntu are you using?Abstractionism
it's Ubuntu 14.04 LTS. I was thinking maybe it's somehow possible to add some line in sources list, run apt-get update, and then apt-cache policy will show me the packageBombacaceous
you have got the right idea. You just need to find the source line now. as a side question, may I know why do you need that specific version. For all practical reasons php5.5 is better than php5.3. It is necessarily php5.3 with more bug fixes. That is the reason why repos have replaced php5.3 with php5.5Abstractionism
M
0

Try:

sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install phpX.Y # E.g. 7.4

Source: How to Install PHP 7.4 on Ubuntu 20.04 LTS.

Misty answered 29/8, 2022 at 16:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.