How to Check PHP is installed on ubuntu / linux or not ?

Open a shell terminal either by using the Ctrl+Alt+T keyboard shortcut or by clicking on the terminal icon.
Now there are many possible ways to do this. Here are they :

1.

# php --version
PHP 7.2.22-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 2 2019 12:54:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.22-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
# php -v
PHP 7.2.22-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 2 2019 12:54:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.22-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

As you can see from both the command output above, the system has PHP 7.2.22 installed.

2. Let’s create a PHP file with content as shown below. The phpinfo() function outputs a great deal of information about the state of the current PHP environment, including loaded extensions, compilation options, version, server information, and so on.

# echo "<?php phpinfo();?>" > /var/www/html/phpinfo.php

3. Now, considering that Apache is installed and working, open a browser and test PHP using address as follow:

http://server/phpinfo.php


Related articles : number_format(), printf(), sprintf(), sscanf(), import database using command line in MySQL.


 

You may also like...