
PHP (Hypertext Preprocessor) is an open-source server-side scripting language widely used for web development. It enables developers to build dynamic websites, process form data, manage sessions, and integrate with databases like MySQL and PostgreSQL. PHP is highly extensible and supports multiple extensions you can use to build modern web applications.
This article explains how to install PHP 5.6 on Ubuntu 24.04. While PHP 5.6 has reached end-of-life, multiple applications still depend on it. You will install PHP 5.6 and configure PHP-FPM to integrate it with applications such as web servers.
Before you begin, you need to:
PHP 5.6 reached its end of life (EOL), and it's not available in the official Ubuntu repositories by default. However, you can still install it through the Ondřej Surý Personal Package Archive (PPA) source.
Add PHP PPA to the APT package repository sources.
Update the APT package index.
Follow the steps below to install PHP 5.6 and all necessary dependencies.
Install PHP 5.6, along with the command-line interface (CLI) and common PHP modules.
Verify the installed PHP version.
Your output should be similar to the one below.
If multiple PHP versions are installed on your workstation, use sudo update-alternatives --config php to set PHP 5.6 as the default version.
PHP-FPM (FastCGI Process Manager) handles PHP script execution efficiently when integrating it with web servers like Apache or Nginx. PHP-FPM is a process manager that runs PHP as a separate background service, handling requests independently from the web server, resulting in improved performance. Follow the steps below to install PHP 5.6 FPM to use it with other applications like web servers.
Install PHP-FPM for PHP 5.6.
Start the PHP-FPM service.
Enable the PHP-FPM service to automatically start at boot.
View the PHP-FPM service status and verify that it's running.
Your output should be similar to the one below.
You can use PHP in different environments, such as the command line, interactive shells, and web server applications. Follow the steps below to test and verify the PHP installation on your server.
Create a new test.php file in your web root directory, such as /var/www/html.
Add the following PHP code to the file.
Save and close the file.
Execute the PHP script.
Output:
Follow the steps below to run PHP 5.6 with a web server such as Apache.
Create a new phpinfo.php file in your web root directory, such as /var/www/html.
Add the following PHP code to the file.
Save and close the file.
Enable the proxy_fcgi module for Apache to communicate with PHP-FPM and the setenvif module to manage environment variables.
Restart the Apache service to apply the module changes.
Open the 000-default.conf Apache virtual host configuration.
Add the following configuration block within the <VirtualHost *:80> section to enable Apache to process PHP requests using the PHP 5.6 FPM socket.
Save and close the file.
Test the Apache configuration for syntax errors.
Output:
Restart the Apache web server to apply the changes.
Allow HTTP connections through the firewall.
Reload the firewall configuration.
Access the /phpinfo.php path using your server's IP address in a web browser such as Chrome.
Verify that your PHP 5.6 information displays in the web browser and all installed extensions.
PHP 5.6 reached its End of Life (EOL), meaning it no longer receives security patches, updates, or support. Running PHP 5.6 could expose your server to security vulnerabilities and compatibility issues. Only use outdated PHP versions on legacy systems that require them for specific applications.
You have installed PHP 5.6 on Ubuntu 24.04 and configured it to run with PHP-FPM. You can execute PHP scripts from the command line, the PHP shell, or serve applications on your web server using Apache or Nginx. Visit the PHP 5 Documentation for more information.
0 Comments
Be the first to comment and share your perspective with the community.