If you support legacy applications like I do, you'll sometimes need to support older version of php. PHP 5.3 is an outdated and unsupported version. Do this for legacy applications only in controlled environments.
You have two options:
sudo apt update
sudo apt install docker.io -ydocker pull php:5.3-apacheCreate a file index.php in your desired application directory (e.g., /path/to/your/app) with the following content:
<?php
echo '<h1>PHP Version: ' . phpversion() . '</h1>';
?>Run the Docker Container
docker run -d -p 8080:80 -v /path/to/your/app:/var/www/html --name php53-container php:5.3-apache
In the previous command, --name php53-container: Assigns the name php53-container to the container
Be sure to replace /path/to/your/app with your application directory
Access your app by visiting http://localhost:8080 in your browser, if you used the example index.php file I provided, you should see "PHP Version: 5.3.29"
Switch to Root
sudo suGenerate Locale
locale-gen en_US.UTF-8Backup Configuration Files
cp -R /etc/php /etc/php_backup
cp -R /etc/apache2 /etc/apache2_backupList Existing PHP Packages
dpkg -l | grep phpRemove PHP and Apache (Replace <php-packages> with the actual package names from the previous step):
apt purge <php-packages> apache2 -ySince PHP 5.3 isn't in modern repositories you'll need to manually download .deb files for PHP 5.3 from an archive or PPA like ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php5.3 apache2Navigate to the default web root:
cd /var/www/htmlRemove any default index.html:
rm index.htmlCreate a new index.php file
echo "<?php echo '<h1>PHP Version: ' . phpversion() . '</h1>'; ?>" > index.phpsudo systemctl restart apache2Open your browser and navigate to http://localhost or the server's IP address.
You should see a page displaying the PHP version.