PHP 5.6 is an older version of PHP that may be required for specific applications or legacy projects. Debian 11, codenamed “Bullseye,” is the latest stable release of the Debian operating system. In this step-by-step guide, we will walk you through the process of installing PHP 5.6 on Debian 11.
Step 1: Update Your System:
Before proceeding with the PHP installation, it’s essential to ensure your system is up-to-date. Open a terminal and run the following commands:
sudo apt update
sudo apt upgrade
Step 2: Add Dotdeb Repository:
PHP 5.6 is not available in Debian 11’s default repositories. We’ll use the Dotdeb repository, which provides packages for older PHP versions. Install the required dependencies and the Dotdeb repository using the following commands:
sudo apt install -y curl gnupg2
curl -sS https://www.dotdeb.org/dotdeb.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/dotdeb.gpg
echo "deb http://packages.dotdeb.org $(lsb_release -cs) all" | sudo tee /etc/apt/sources.list.d/dotdeb.list
sudo apt update
Step 3: Install PHP 5.6:
With the Dotdeb repository added, we can now install PHP 5.6 along with necessary extensions. Run the following commands:
sudo apt install -y php5.6 php5.6-common php5.6-cli php5.6-fpm php5.6-mysql php5.6-curl php5.6-gd php5.6-mbstring php5.6-xml
Step 4: Check PHP Version:
After installation, verify PHP 5.6 is installed correctly by checking its version:
php5.6 -v
Step 5: Configure PHP 5.6:
Next, we’ll make some configuration changes to ensure PHP 5.6 works correctly. Open the PHP configuration file with a text editor:
sudo nano /etc/php/5.6/cli/php.ini
Make any necessary changes according to your project requirements. Save the file and exit the text editor.
Step 6: Switch Between PHP Versions (Optional):
If you have multiple PHP versions installed on your system, you can switch between them using the update-alternatives
command. To set PHP 5.6 as the default version, run:
sudo update-alternatives --set php /usr/bin/php5.6
Congratulations!
You have successfully installed PHP 5.6 on Debian 11. You can now develop and run projects that require this specific PHP version. However, please note that PHP 5.6 is no longer actively supported, and it’s crucial to consider upgrading to a supported PHP version for security and performance reasons. Enjoy coding!
I specialize in cloud technologies. So in a few years, he has become one of our top field specialists and has moved from intern's potion to a fully trained professional DevOps in an impressive fashion. I work in a wide range of areas that require in-depth knowledge, such as working with Linux-based infrastructure; setting up and managing databases; CI/CD platforms, Kubernetes; Helm, Docker; Python, Ansible; TCP/IP, DNS, HTTP/HTTPS, SSH. I am also fond of hunting, fishing and traveling. You can see more information about me on my social media pages.