Upgrading PHP to 7.4 in ubuntu Apache Server
sudo apt update sudo apt install -y curl wget gnupg2 ca-certificates lsb-release apt-transport-https
Add the repository to your system.
sudo apt-add-repository ppa:ondrej/php
Update the repository index.
sudo apt update
Once you have added the PPA you can install PHP 7.4 and its extentions
Install PHP 7.4 for Apache,Execute the following command to install PHP 7.4
sudo apt install php7.4 php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y
Check the php version after install
Enable PHP 7.4 for Apache
Now you need to tell Apache to use the installed version of PHP 7.4 by disabling the old PHP module (below I have mentioned php7.0, you need to use your current php version used by Apache) and enabling the new PHP module using the following command.
sudo a2dismod php7.0 sudo a2enmod php7.4
Restart Apache for the changes to take effect.
sudo service apache2 restart
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
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.