Install PHP on Ubuntu.

What is PHP?

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. It is a server-side scripting language that powers millions of website, including many platforms like WordPress, WHMCS, and much more. This guide will help you to Install PHP on Ubuntu server as well as help you secure it.

Before proceeding to the guide, please install Apache using out Install Apache Web Server on Ubuntu Guide. As it is or another alternative to it is required for PHP.

Install PhpMyAdmin as well, as it is part of LAMP too. Use our other guide for that – Install PhpMyAdmin on Ubuntu.

LAMP Installation.

While installing Ubuntu, near the end of the installation, you will get this kind of list, where you can install LAMP server (Linux Apache MySQL and PHP). If you select it here, then you have to do nothing, as it is preinstalled on your system. However, if you haven’t, Please follow the guide further.

LAMP Installation

LAMP Installation

Install PHP on Ubuntu

Installing PHP is easy, Just one command. The following command.

sudo apt-get update && apt-get install php

That’s it.

Additional PHP Packages.

The following packages are the addition to PHP, these may or may not help your website (It mostly will).

apt-get install php-pear php-db php5-gd php5-curl libssh2-php php5-mysql

PHP Tweaks.

One of the PHP tweaks we recommend is the following.

Open php.ini by typing the following command.

locate php.ini

Then search for the expose_php = On and change it to the following:

expose_php = Off

This change will stop your server from revealing the PHP details (by adding its signature to the web server header) on your server along with other information. It may not be a security threat per say, but it always better to keep your settings/config hidden and away from hackers anyway.

Once the above changes are done, just run the following command to put it in play.

sudo service apache2 restart

That is it. That is how you Install PHP on Ubuntu and secure it too.

Do consider subscribing to our Linux VPS services for it, we have preinstalled Ubuntu as well that comes with various panels.