If you want to update your PHP version, or just get a different one, you can proceed with the corresponding PHP steps in the following link:  http://www.offset101.com/2017/04/18/setup-lamp-server-scratch/

If you want to remove a previous installed or a useless PHP you should do the following:

Once you have updated your PHP, you should be aware that you will have a php.ini per cli and apache2 (just in case you needed to add remove or change an extension):

apache2: The fastest way to get it, is adding a phpinfo();die(); withing your code, and find the “Loaded Configuration File” row (this should be under /etc/php/7.0/apache2/php.ini)

cli: The fastest way to get it, is doing a php –ini, and before all the installed packages, you will see the “Loaded Configuration File” row for cli (which should be under /etc/php/7.0/cli/php.ini)

Switch version from PHP 5.6 to PHP 7.0:

  • Apache:
  • CLI:

Switch version from PHP 7.0 to PHP 5.6:

  • Apache:
  • CLI:

If you don’t want to change between versions, you can create an alias inside your /home/user/.bashrc file to use (for example) the php7, to do so, you can add the following line:

and you will be able to do “php7 <file>” using php7.