PHP is the most popular scripting language used in website and web applications development. The PHP language is released under open-source standards, also object-oriented and interpreted scripting language that can be executed at the server-side. Being an interpreted language it means there is no need for compilation as the application executes directly on the server to generate dynamic pages.

As of this article update the latest release of PHP available for installation is PHP 7.4. PHP is a simple language and easy to learn for those getting started with web development. PHP can also be embedded into HTML pages. This article will discuss the process of installing PHP on Linux Mint 20.

How To Install PHP on Linux Mint 20

You should have a running Linux Mint 20 installation to use this guide. Login as a user with sudo access and update your APT index,

sudo apt update

Once done then you can install PHP on Linux Mint 20. The default version available is PHP 7.4.

The command below will install PHP and standard extensions.

sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd  php-mbstring php-curl php-xml php-pear php-bcmath

Accept installation prompt.

The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php7.4 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libonig5 php
  php-bcmath php-cli php-common php-curl php-fpm php-gd php-json php-mbstring php-mysql php-pear php-xml php-zip php7.4 php7.4-bcmath php7.4-cli
  php7.4-common php7.4-curl php7.4-fpm php7.4-gd php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-zip
0 upgraded, 37 newly installed, 0 to remove and 58 not upgraded.
Need to get 8,322 kB of archives.
After this operation, 35.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Confirm installation of PHP on Linux Mint 20:

$ php --version
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

If you don’t want Apache web server disable its service.

sudo systemctl disable --now apache2

Other extensions of PHP can be installed using apt command by substituting <extension-name> with the extension you want to install.

sudo apt install php-<extension-name>

The example below installs PHP redis and memcache modules.

sudo apt install php-memcache php-redis

You now have PHP installed on your Linux Mint 20 system. if you intend on using PHP with nginx, the server can be installed by running the command below as sudo user.

sudo apt install nginx

Refer to nginxconfig.io for easy configuration of Nginx with PHP FPM.

Other Linux Mint guides:

Install Java / OpenJDK on Linux Mint

Install Visual Studio Code (VSCode) on Linux Mint

LEAVE A REPLY

Please enter your comment!
Please enter your name here

ten + eight =