
Good content takes time and effort to come up with.
Please consider supporting us by just disabling your AD BLOCKER and reloading this page again.
You will have lot of problems when your local development PHP
version might be different then that of production PHP
version, this might further cause some issues when you run composer
commands.
Not only this if you need to upgrade your PHP
frameworks like LARAVEL
, SYMFONY
you have to install newer version of PHP
. You might also upgrade because fo security patches. So in this tutorial I will teach you how to install multiple PHP
versions and how to switch to different PHP
version as per your requirements.
First login to your server and update the Ubuntu/Linux packages with the following command
sudo apt-get update
You can check if you had earlier installed PHP
by using the following command. It will list the PHP
version installed
sudo php -v
You might need to install additional packages like PPA
, if your operating system has not yet released the PHP version your looking out for then 3rd party PPA Ondrej
will help to download the latest one.
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
Once you install the above packages again you have to update your ubuntu server packages so that it will download the latest software packages from these repositories
sudo apt-get update
Now install the different versions of PHP so that you can see how easy it is to switch between them
APACHE
web serversudo apt-get install php5.6
sudo apt-get install php7.1
sudo apt-get install php7.2
Additionally if you need you can install other packages along with them like the following
sudo apt-get install php5.6 php5.6-cli php5.6-curl php5.6-mysql php5.6-mbstring sudo apt-get install php7.1 php7.1-cli php7.1-curl php7.1-mysql php7.1-mbstring sudo apt-get install php7.2 php7.2-cli php7.2-curl php7.2-mysql php7.2-mbstring
NGINX
web serversudo apt-get install php5.6-fpm
sudo apt-get install php7.1-fpm
sudo apt-get install php7.2-fpm
Additionally if you need you can install other packages along with them like the following
sudo apt-get install php5.6-fpm php5.6-cli php5.6-curl php5.6-mysql php5.6-mbstring sudo apt-get install php7.1-fpm php7.1-cli php7.1-curl php7.1-mysql php7.1-mbstring sudo apt-get install php7.2-fpm php7.2-cli php7.2-curl php7.2-mysql php7.2-mbstring
You can see list of all the php version releases in official website PHP Releases
By default any one of the PHP version will be activated after installing all the packages. At any point of time you can check which PHP version is currently active with the following command
sudo php -v
You may get the output like the following
PHP 7.2.24-0ubuntu0.18.04.4 (cli) (built: Apr 8 2020 15:45:57) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.24-0ubuntu0.18.04.4, Copyright (c) 1999-2018, by Zend Technologies
PHP 7.1
As Default Versionsudo update-alternatives --set php /usr/bin/php7.1
PHP 5.6
As Default Versionsudo update-alternatives --set php /usr/bin/php5.6
7.2
to 5.6
First disable the PHP 7.2
version with a2dismod
, then enable PHP 5.6
version with a2enmod
then restart APACHE
server
sudo a2dismod 7.2
sudo a2enmod 5.6
sudo service apache2 restart
To get back PHP 7.2 as default version just follow the above steps by changing the version you want to enable and disable.
Now you got to know how to switch between the PHP versions.
Generate SSH Key with ssh-keygen In Linux / Unix
Getting Started With AMP (Accelerated Mobile Pages)
composer.json v/s composer.lock
Install RabbitMQ with Docker & Running with NodeJS
Integrate Google Translate Into Your Website
Unable to prepare route [{fallbackPlaceholder}] for serialization. Uses Closure In Laravel
Basic Server Security Setup For Ubuntu / Linux
Free SSL Certificate For CPanel
Factory States For Clean And Fluent Laravel Testing
Upload File From Frontend Server {GuzzleHttp} To REST API Server In PHP {Laravel}
Comment And Like System Using Disqus
@stack @push and @prepend In Laravel Blade