In this PHP Tutorial, I will let you know how to install or upgrade PHP version from 7.3 to 7.4 using command on your linux machine.
With every new version, you get number of new features so you should start developing your application in newer version always.
There are some cases in which you have to upgrade your PHP version but before upgrading to any version from previous one, you should be always aware from its incompatibilities.
There is very simple step that you need to follow to update your PHP version to newest.
Add PPA for PHP 7.4First, You need to add the PPA ondrej/php
which will provide the PHP 7.4 package and other required PHP extensions.
sudo add-apt-repository ppa:ondrej/php sudo apt-get update
After successfully adding the PPA, you can install any version of PHP 7.
sudo apt install php7.4
Now you can run following command to install commanly used php-extensions
:
sudo apt install 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
If you are using PostgreSQL for database connection then you need to install below extension :
sudo apt-get install php7.4-pgsql
If you have already installed any other version of PHP then you should disable that version first and then enable the current version of PHP that you want to use for your application by running following command:
sudo a2dismod php7.3 sudo a2enmod php7.4
Now restart your apache server by running below command:
sudo service apache2 restart
You are done with the steps and now you can check the PHP version by running following command:
php -v