HemanJone
1 post
Jul 23, 2025
8:55 AM
|
For developers and system administrators working with legacy applications, PHP 7.4 remains a vital version. Many businesses and platforms still depend on this stable release due to its compatibility with frameworks like older versions of Laravel, WordPress, and Magento. If you're using Ubuntu 24.04 and need to run these projects, knowing how to install PHP 7.4 on Ubuntu is essential. This guide, based on the official Vultr documentation, walks you through the steps to install PHP 7.4 and get your projects up and running smoothly.
Why Use PHP 7.4 on Ubuntu 24.04? Ubuntu 24.04 comes with more recent PHP versions by default. However, not all applications are ready for newer PHP releases due to deprecated functions or changes in syntax. PHP 7.4 offers stability and performance, making it an ideal choice for applications not yet updated to PHP 8.x. By following a few simple steps, you can install PHP 7.4 alongside other versions without conflicts, making your development environment more flexible and compatible.
Step 1: Update System Packages Start by updating your system to ensure you’re working with the latest repositories and security patches. sudo apt update && sudo apt upgrade -y
This helps avoid compatibility issues during installation. Step 2: Add the PHP 7.4 Repository Since PHP 7.4 isn’t included in the default Ubuntu 24.04 repository, you’ll need to add a trusted third-party PPA provided by Ond?ej Surý, a reputable maintainer of PHP packages. sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update
This command sequence adds and refreshes the repository list, making PHP 7.4 available for installation. Step 3: Install PHP 7.4 and Required Modules Now that the repository is added, you can install PHP 7.4 and commonly needed extensions for your projects: sudo apt install php7.4 php7.4-cli php7.4-mysql php7.4-curl php7.4-mbstring php7.4-xml php7.4-zip php7.4-bcmath php7.4-soap php7.4-intl -y
These modules support database interactions, file uploads, XML processing, encryption, and internationalization—critical functions for many web applications.
Step 4: Verify Installation Once installed, confirm that PHP 7.4 is active: php -v
This should return a version string indicating PHP 7.4.x is installed and working.
Step 5: Configure Apache or Nginx (Optional) If you’re using Apache and want to serve PHP 7.4-based applications: sudo a2dismod php8.1 sudo a2enmod php7.4 sudo systemctl restart apache2
For Nginx, you’ll need to configure PHP-FPM: sudo apt install php7.4-fpm
Then point your Nginx server block to use the php7.4-fpm.sock. Step 6: Set Up a PHP Project Once PHP 7.4 is ready, clone or copy your project into your server’s web root directory (e.g., /var/www/html) and adjust permissions accordingly: sudo chown -R www-data:www-data /var/www/html/yourproject
Restart your web server and navigate to your app’s URL to test. Conclusion Running legacy or stable PHP 7.4 projects on Ubuntu 24.04 is not only possible—it’s straightforward with the right tools and repository. By using the steps outlined in the Vultr guide, you can quickly install PHP 7.4 on Ubuntu and ensure your applications remain secure, functional, and efficient. Whether you’re managing a production environment or setting up a dev server, this method ensures full compatibility with your existing PHP 7.4 codebase.
|