top of page

Switch PHP version in Ubuntu & Apache

For example, if you are using the PHP 7.2 version and you are looking to switch the version to PHP 7.4.


We need to update the PHP version in two places.

  1. CLI

  2. Apache

1. Switch PHP version in CLI


Before that check your PHP current version in the terminal by using the below command.


php -v

Then run the below command to switch the PHP CLI version.


sudo update-alternatives --set php /usr/bin/php7.4

Then again check your PHP version to make sure it was updated.


php -v

2. Switch PHP version in Apache webserver


Before that check the apache using PHP version by phpinfo(). Then disable the apache using the php version. As per the example, apache using 7.2 so we are going to disable PHP 7.2 in apache.

sudo a2dismod php7.2

Then enable the needed version, as per the example, we are going to enable 7.4

sudo a2enmod php7.4

Finally, restart the apache webserver.

sudo service apache2 restart

Please check the phpinfo() to make sure the PHP version updated in apache.


I hope it helps. Thanks.



 
 
 

Recent Posts

See All
Split file by line number - Ubuntu

We can run the below command to split the large file in Ubuntu. split --numeric-suffixes=1 --additional-suffix=.csv -l 100 original.csv...

 
 
 

Comments


Follow Me

  • LinkedIn
  • Twitter
  • Facebook
  • YouTube
  • Instagram

©2021 by Bilal Usean. Proudly created with Wix.com

bottom of page