Showing posts with label php 5.3 inside docker. Show all posts
Showing posts with label php 5.3 inside docker. Show all posts

Tuesday, June 8, 2021

php 5.3 / 5.4 on Ubuntu 20.04 / 18.04

Deploy php 5.3 or php 5.4 web application on latest Ubuntu LTS 20.04 or Ubuntu 18.04

If you want to deploy your older php application on latest Ubuntu or Centos server, 32 bit library error can be an issue. You might have tried to download and install older version of xampp but your newer 64 bit OS does not support 32 bit xampp hence you are not able to install it.

Do not worry about the issue. Here is the solution for you.

You need to install xampp inside a docker container and deploy your application there.

1. Install docker.

There are plenty of guides available which can help you to install docker on your Linux OS. Once docker is installed, follow the guide.

2. Pull an Ubuntu 12.04 image using command.

docker pull ubuntu:12.04

3. Launch a container. Here we need to map host system's port 80 with docker container's port 80 and /opt folder of host system with /opt folder of container. You can choose different port and directory of host system also.

But if you choose port 80 of host system, make sure no service is running on it. Kill all the services of port 80 of host and launch a container with mapped port 80 and mapped volume /opt using following command.

docker run -i -t -p 80:80 -v /opt:/opt ubuntu:12.04 /bin/bash

4. Now you are inside the container. You can confirm by command `uname -m` that it is 32 bit, now you can install xampp of required php version.

To reach inside the directory /opt of container, Run command

cd /opt; ls

You should be able to see all the folders of /opt of your host system in the container.

5. Now open your browser and download the xampp of php 5.3.5 using following url.

https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/1.7.4/xampp-linux-1.7.4.tar.gz

Extract the compressed file and copy folder lampp in /opt.

If you have an existing folder lampp in /opt, make sure you have renamed it before copying php 5.3.5 lampp in the /opt, otherwise it can overwrite your existing lampp setup.

6. Start the lampp in the container terminal using command

/opt/lampp/lampp start

If you have closed the container terminal, login again using following commands.

sudo service docker start

sudo docker start `sudo docker ps -a | grep "12.04" | awk '{print $1}'`

sudo docker exec -t `sudo docker ps -a | grep "12.04" | awk '{print $1}'` /bin/bash

/opt/lampp/lampp start

7. Once lampp is started successfully, open a tab in the browser and open url

http://localhost/

You should be able to open xampp dashboard. Verify php version on phpinfo page.

Deploy the application in the same way you deploy on your host system.

Note : 

1. If you want to shift on existing lampp, stop the container and rename the current lampp as 12.04 and existing lampp as lampp in /opt.

2. Whatever changes you make in lampp folder of 12.04 in /opt host system, it will be updated in the container because /opt of host system is mapped with /opt of container.