Intro:
PHP is a server-side scripting language and it is used as a web programming language. PHP should be installed on a webserver to run and execute PHP code. PHP is free, as well as open-source.
Stage 1: PHP Repository to be Enable:
First, we need to update our system then execute software-properties-common and ppa: ondrej/php commands.
~# sudo apt-get update
~# sudo apt-get update
~# sudo apt -y install software-properties-common
~# sudo add-apt-repositaryppa:ondrej/php
Stage 2: Install PHP 7.4 on an ubuntu machine:
~# sudo apt-get install php7.4
Verify the php version, by using below command shown below:
~# php -v
If you want to install more packages at a time, use the below command
You can see your list of php modules
~# php -m
Stage 3: Execute PHP Sample file on Ubuntu:
We need to create a PHP file in the location of /var/www/html/directory.
~# sudo vi /var/www/html/sample.php
Under sample.php use the below code to test it.
<?php
phpinfo();
?>
Save and close it.
Now, open the browser and go tohttp://IP_address:sample.php