How to Install PHP 7.2 on Linux Mint 19
Table of Contents
Install PHP 7.2 on Linux Mint 19
PHP has different versions 5.6, 7.0, 7.1 and 7.2. Currently, PHP 7.2 is the latest version of it. PHP 7.2 offers much better performance and faster request processing and some security updates. Linux Mint 19 ships with PHP 7.0 which will no longer receive security updates so you should migrate from PHP 7.0 to PHP 7.2. In this tutorial, you will learn to install PHP 7.2 on Linux Mint 19.
Before you start to install PHP on Linux Mint 19. You must have the non-root user account on your server with sudo privileges
1. Installing PHP on Debian
To install PHP 7.2 on Linux Mint 19, First, you will need to install some missing packages so you can add a new repository over HTTPS. Then you will add GPG keys after you will install PHP.
Update the package manager index by typing following in the terminal
sudo apt update
Now add missing package so you can add a new repository over HTTPS.
sudo apt install ca-certificates apt-transport-https
An import signing key and enable PPA for PHP 7.2 by using the following command.
curl -fsSL https://packages.sury.org/php/apt.gpg | sudo apt-key add - sudo add-apt-repository "deb https://packages.sury.org/php/ $(lsb_release -cs) main"
Now update the package manager index again and install PHP 7.2 in Debian.
sudo apt update sudo apt install php7.2
Confirm the installation and check the version of PHP by typing:
2. Setup PHP for Nginx
Nginx by default does not support native PHP processing. You will need to install “fastCGI process manager”. Run the following command to install php-fpm on your server.
sudo apt install php-fpm
You can check the status where it is correctly installed or not by the following command
systemctl status php7.2-fpm
After installing the php-fpm package you will need to restart the Nginx server. To restart Nginx server run following command
sudo systemctl restart nginx
you can check PHP version by running following command
3. Installing PHP With Apache
If you are running Apache at backend then you need to install PHP and Apache PHP module on the server. To install PHP 7.2 and apache module type following command and press enter.
sudo apt install php libapache2-mod-php
After installing the PHP and apache-php module you will need to restart the Apache server by typing the following command.
sudo systemctl restart apache2
4. Install PHP Extensions
You will need to install some basic PHP extensions to run WordPress, Laravel like frameworks on the server. To install any of the PHP extensions on the server following is the basic format
sudo apt install php-[name_of_the_extension]
You can install a curl extension for PHP by running the following command.
sudo apt install php-curl
The following are some basic PHP extensions that need to be installed on your server.
sudo apt install php7.2-curl php7.2-mysql php7.2-common php7.2-cli php7.2-gd php7.2-opcache php7.2-mcrypt
To install more extensions you can use the above format.
5. Testing PHP processing
To test PHP is configured on your server properly or not you should create a file test.php inside directory /var/www/html/ with following code.
If you see the following output at https://YOUR_DOMAIN_NAME/test.php then you have installed PHP successfully.
You have installed PHP 7.2 on Linux Mint 19 successfully with some of its basic extensions and tested successfully. If you have any of the queries regarding this then don’t forget to comment below.
Secure Nginx with Let’s Encrypt SSL on Ubuntu 18.04
How to Install Opera Browser on Debian 10
Generate Random Unique String in Laravel
How to Install Webmin on Ubuntu 18.04
How to Install Adobe Flash Player on Ubuntu
How to Install DataGrip on Ubuntu 18.04
How to Rename Local and Remote Branches in Git
How to Install XAMPP on Debian 10
How to Stop and Disable FirewallD on CentOS 8
How to Install Go on Debian 10
How to Install WebStorm on Ubuntu 18.04
How to Create Symbolic Links Using ln Command in Linux