ncux
ncux

Reputation: 59

How to update Apache's PHP?

I installed Laravel 5.6, but it's not working because it requires PHP 7.2. I use Ubuntu 17, and installed Apache 2 and PHP 7.2 (7.1, 7.0) but when I use phpinfo() it shows php7.0. So how can I config Apache and set php7.2 instead of php7.0?

Upvotes: 5

Views: 13847

Answers (2)

Mohammad Zare Moghadam
Mohammad Zare Moghadam

Reputation: 688

At first you have to install php7.2 with the following commands

sudo apt install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y php7.2
sudo apt install libapache2-mod-php7.2 php7.2-cli php7.2-curl php7.2-intl php7.2-mysql php7.2-opcache php7.2-json php7.2-bz2 php7.2-mcrypt php7.2-xmlrpc php7.2-mbstring  php7.2-soap php7.2-xml php7.2-zip

After installing php you have to run the following commands:

sudo update-alternatives --set php "/usr/bin/php7.2";
sudo update-alternatives --set "php-config" "/usr/bin/php-config7.2";
sudo a2dismod "php7.0"
sudo a2dismod "php5.6"
sudo a2enmod "php7.2"
sudo service apache2 restart

If you installed php7.2-dev then you should run the following command too:

sudo update-alternatives --set "phpize" "/usr/bin/phpize7.2";

Upvotes: 10

Prince Lionel N'zi
Prince Lionel N'zi

Reputation: 2588

Run the following commands to have PHP 7.2 installed

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt-get install php7.2-cli

After that, you can run the command below to see the installed version of PHP:

php -v

Upvotes: 1

Related Questions