To install PHP cURL, PHP GD library, and the ZipArchive extension for PHP 7.4 on a Debian 12 server running YunoHost, follow these steps:
—
1. Update the Package Manager
Ensure your system’s package manager is up to date:
sudo apt update && sudo apt upgrade -y
—
2. Add PHP 7.4 Repository (Optional)
Debian 12 (Bookworm) may not have PHP 7.4 available by default because it is an older version. You may need to add an external repository (like Sury's PHP repository) to install PHP 7.4.
Add the Sury Repository:
sudo apt install -y apt-transport-https lsb-release ca-certificates
sudo wget -qO /etc/apt/trusted.gpg.d/sury.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update
—
3. Install PHP 7.4 and Required Extensions
Use the following command to install PHP 7.4 and the required modules:
sudo apt install -y php7.4 php7.4-curl php7.4-gd php7.4-zip
—
4. Verify Installation
Check that the extensions are installed and enabled:
a. List Installed PHP Extensions:
php7.4 -m
Look for curl
, gd
, and zip
in the list of installed modules.
b. Check the PHP Version:
php7.4 -v
This confirms the PHP 7.4 version is active.
—
5. Restart Services
After installing or modifying PHP extensions, restart your web server to apply changes. YunoHost typically uses nginx:
sudo systemctl restart php7.4-fpm
sudo systemctl restart nginx
—
6. Set PHP 7.4 as Default (if Necessary)
If you have multiple PHP versions installed, you may need to set PHP 7.4 as the default for CLI or web services:
a. Set Default for CLI:
sudo update-alternatives --set php /usr/bin/php7.4
b. Set PHP-FPM to Use 7.4:
Edit the Nginx configuration for the specific app or globally if needed:
sudo nano /etc/nginx/conf.d/your_domain.conf
Ensure the configuration points to php7.4-fpm
. After changes, reload nginx:
sudo systemctl reload nginx
—
7. Test Extensions
Create a PHP file (e.g., /var/www/html/phpinfo.php
) to test if the extensions are enabled:
a. Create a Test File:
sudo nano /var/www/html/phpinfo.php
Add the following code:
<?php
phpinfo();
?>
b. Access via Browser:
Visit http://your-domain/phpinfo.php
and look for curl
, gd
, and zip
under the “modules” section.
—
Let me know if you encounter any issues!