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 -y
docker pull php:5.3-apache
Create 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 su
Generate Locale
locale-gen en_US.UTF-8
Backup Configuration Files
cp -R /etc/php /etc/php_backup
cp -R /etc/apache2 /etc/apache2_backup
List Existing PHP Packages
dpkg -l | grep php
Remove PHP and Apache (Replace <php-packages>
with the actual package names from the previous step):
apt purge <php-packages> apache2 -y
Since 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 apache2
Navigate to the default web root:
cd /var/www/html
Remove any default index.html:
rm index.html
Create a new index.php file
echo "<?php echo '<h1>PHP Version: ' . phpversion() . '</h1>'; ?>" > index.php
sudo systemctl restart apache2
Open your browser and navigate to http://localhost or the server's IP address.
You should see a page displaying the PHP version.