How to Change PHP Version in Ubuntu Server?
Hi,
This article goes in detailed on how to change php version in ubuntu. you can see how to change php version command line. if you have question about how to change php version in ubuntu 20.04 then i will give simple example with solution. I’m going to show you about change php version linux.
If you installed multiple php version in your ubuntu system or server and you need to change default php version then i will help you with different ways to change php version in ubuntu 21.10, ubuntu 21.04, ubuntu 20.04, ubuntu 18.04 and ubuntu 16.04.
let's see commands one by one.
Way 1: Change PHP Version
you can change php version by following command:
sudo update-alternatives --config php
you have to choose from list as bellow:
now let's restart server:
sudo service apache2 restart
Way 2: Change PHP Version
Here, you need to a2dismod old version and a2enmod new php version so let's run following command:
sudo a2dismod php7.3
sudo a2enmod php7.4
now let's restart server:
sudo service apache2 restart
Way 3: Change PHP Version
You can direct change php version by following command:
sudo update-alternatives --set php /usr/bin/php7.4
now let's restart server:
sudo service apache2 restart
i hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Install MySQL in Ubuntu Server?
- How to Install PHP in Ubuntu Server?
- How to Install Apache Web Server on Ubuntu Server?
- Node JS CRUD with MySQL Tutorial Example
- How to Connect SSH using ppk File Ubuntu?
- How to Connect to a Remote Server using SSH on Ubuntu?
- How to Upgrade PHP Version from 7.4 to 8 in Ubuntu?
- How to Export Mysql Database using Command Line in Ubuntu?
- How to Import Database in Mysql using Command Line in Ubuntu?
- How to Upgrade PHP Version from 7.2 to 7.3 in Ubuntu?
- How to Enable Apache mod_rewrite Module in Ubuntu?