6

I have a system that requires PHP 5.3 only.

Is it possible to install PHP 5.3 on Ubuntu Server 18.04 LTS?

2 Answers2

13

Besides getting the usual warning regarding outdated packages, you should be able to compile PHP 5.3 on your system.

Taken from this post:

You will need these extra packages:

sudo apt-get install build-essential libxml2-dev checkinstall

Install PHP

In terminal - Download the package into tmp directory (or where ever you want it downloaded to)

cd /tmp && wget http://in1.php.net/distributions/php-5.3.29.tar.bz2

Untar and cd into directory

tar -xvf php-5.3.29.tar.bz2
cd php-5.3.29

Get everything ready and compile - if you get errors you may be missing some packages. You will have to google how to get these missing parts.

./configure
make

Create PHP 5.3 .deb file. This way you can easily uninstall later.

sudo checkinstall

I just tried to compile this on my 18.04 machine and it worked fine. But you may need certain php modules for your project and you may have to find and compile those as well.

You may have to install some missing packages for the .deb file (like Apache, etc.) You can fix that by running this after:

sudo apt-get install -f

Also, I hope this project is an internal one, and not exposed to the internet. But I am sure you are aware of the dangers, right? ;)

G Trawo
  • 1,761
  • I think you forgot to make install – Abdulkader Alrezej Jul 06 '18 at 22:32
  • PHP 5.3.29 (cli) (built: Jul 6 2018 22:34:46) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies – Abdulkader Alrezej Jul 06 '18 at 22:36
  • 1
    @AbdulkaderAlrazj You are welcome. And no, I didn't forget 'make install'. That's taken care of in the 'checkinstall'. It does the install into a .deb file and then installs it for you. – G Trawo Jul 07 '18 at 12:10
  • How to remove this php completely? – Mdumanoj Sep 13 '22 at 05:51
  • @Mdumanoj If you used the checkinstall method: https://askubuntu.com/questions/22200/how-to-uninstall-a-deb-package – G Trawo Sep 13 '22 at 13:39
  • Thanks @GTrawo I purged the php and re-installed using above steps. How can install mysql extension for this version of PHP? apt-get install php5-mysql doesn't help – Mdumanoj Sep 15 '22 at 10:14
  • @Mdumanoj Are you asking for the PHP 5.3 mysql extension? If so, you would have to similarly compile it yourself, since I doubt it's available from any PPA. Are you really in need of PHP 5.3? – G Trawo Sep 15 '22 at 18:25
  • @GTrawo Yes. I need to setup a legacy PHP code base. So I need PHP 5.3 modules. It's using mysql_connect which is removed in latest version of PHP. I know about the security vulnerabilities and I'm not going to run it on production. – Mdumanoj Sep 16 '22 at 05:02
0

Yes it's possible but you need to compile php manually. In addition to the above comment, ./configure make (you'll need to include what modules that you wish to add to the compilation)

Kin
  • 1