Install PHP 7.4 on Debian 10. This guide let you learn how install the latest PHP version 7.4 on your Debian system or your Debian server on any VPS or any Cloud or any Dedicated hosting and configure it with Apache and Nginx.
The latest PHP 7.4 version is officially released on November 28th, 2019. It comes with a number of new features and a few incompatibilities that you should be aware of before upgrading from the previous version.
This installation is tested on Google Cloud Platform with a Compute Compute Engine VM Instance. So this set up is guaranteed to work on all Linux based servers.
Prerequisites
- A Debian server set up
with sudo
privileges . - Completed the initial Debian server setup.
If you are using Google Cloud Platform to install PHP you need the following steps to be done.
- A running Compute Engine, see the Setting up Compute Engine Instance with Debian 10.
Here are some cloud hosting providers you can choose from with very low cost and free trial.
Platform | RAM | SSD | Cost |
Kamatera Cloud | 1 GB | 20 GB | $4/mo |
Alibaba Cloud | 1 GB | 20 GB | $8/mo |
Getting Started
Make sure your Debian server is having the latest packages by running the following command.
sudo apt update
sudo apt upgrade
This will update the package index and update the installed packages to the latest version.
Download SURY PPA for PHP 7.4
Download the Sury PPA for PHP 7.4 package using wget
.
sudo apt -y install lsb-release apt-transport-https ca-certificates wget
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
Once you have downloaded the PPA you can add it to the server.
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
Now you can proceed the installation of PHP 7.4 bu udpating the system.
sudo apt update
Install PHP 7.4 for Apache
Execute the following command to install PHP 7.4
sudo apt install php7.4
After the installation has completed, you can confirm the installation using the following command
php -v
Install PHP 7.4 FPM for Nginx
For Nginx you need to install FPM, execute the following command to install PHP 7.4 FPM
sudo apt install php7.4-fpm
After the installation has completed, confirm that PHP 7.4 FPM has installed correctly with this command
php-fpm7.4 -v
Install PHP 7.4 Extensions
Installing PHP extensions are simple with the following syntax.
sudo apt install php7.4-extension_name
Now, install some commonly used php-extensions
with the following command.
sudo apt install php7.4-{common,mysql,xml,xmlrpc,curl,gd,imagick,cli,dev,imap,mbstring,opcache,soap,zip,intl,bcmath} -y
Configure PHP 7.4
Now we configure PHP for Web Applications by changing some values in php.ini
file.
For PHP 7.4 with Apache the php.ini
location will be in following directory.
sudo nano /etc/php/7.4/apache2/php.ini
For PHP 7.4 FPM with Nginx the php.ini
location will be in following directory.
sudo nano /etc/php/7.4/fpm/php.ini
Hit F6
for search inside the editor and update the following values for better performance.
upload_max_filesize = 32M
post_max_size = 48M
memory_limit = 256M
max_execution_time = 600
max_input_vars = 3000
max_input_time = 1000
Once you have modified your PHP settings you need to restart your Apache for the changes to take effect.
Configure PHP 7.4 FPM Pools
PHP 7.4 FPM allows you to configure the user
and group
that the service will run under. You can modify these with these commands
sudo nano /etc/php/7.4/fpm/pool.d/www.conf
Change the following lines by replacing the www-data with your username
.
user = username
group = username
listen.owner = username
listen.group = username
Hit CTRL+X
and Y
to save the configuration and check if the configuration is correct and restart PHP.
Restart PHP 7.4 FPM
Once you have updated your PHP FPM settings you need to restart it to apply the changes.
sudo php-fpm7.4 -t
sudo service php7.4-fpm restart
Now you are having PHP 7.4 Installed and configured.
Prepare yourself for a role working as an Information Technology Professional with Linux operating system
Conclusion
Now you have learned how to install PHP 7.4 on your Debian server.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.
please help me i followed all the steps and upgraded tp php 7.4 but my wordpress site still says am running php 7.0
If you are using Apache then you need to switch PHP version module to use PHP7.4 and restart Apache. You can find more details here https://www.cloudbooklet.com/upgrade-php-version-to-php-7-4-on-ubuntu/
sudo a2dismod php7.0
sudo a2enmod php7.4
sudo service apache2 restart
You need to replace php7.0 with the current PHP version you were using