In this article, we will have explained the necessary steps to install and configure PHP on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
PHP is a recursive acronym for Hypertext Preprocessor and is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. Many popular CMS and frameworks such as WordPress, Laravel and many more are built in PHP.
Install PHP on Ubuntu 20.04
Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.
Step 2. Installing PHP 7.4 on Ubuntu.
Run the following commands to install PHP and Apache PHP module:
Once the packages are installed, restart Apache for the PHP module:
Check your PHP version using the following command:
Step 3. Installing PHP extensions.
PHP extensions are compiled libraries that extend the core functionality of PHP. Extensions are available as packages and can be easily installed with apt:
Step 4. Testing PHP Processing
First, create a test PHP file called info.php in the web server default home directory:
Then copy and paste the line into the file and save it:
After that, open your browser and browse to the server hostname or IP address followed by the name of the file you created above:
http://localhost/info.php or http://my-ip-address/info.php
That’s all you need to do to install PHP on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. Don’t forget to share your valuable queries/suggestions in the below comment box & also drop your worthwhile feedback.