How to install PHP on Ubuntu 14.04

How to install PHP on Ubuntu 14.04

If you don't have have PHP installed, lets get install PHP and Apache

apt-get update && apt-get upgrade

apt-get install -y apache2

At this point you can verify that Apache is installed by opening a browser and going to http://your-ip-address


Now that Apache is installed, we can now install PHP:

apt-get install -y php5 libapache2-mod-php5 php5-mcrypt php5-cli

Once that has completed, it is time to verify that everything is working correctly, lets create a PHP info file:

cd /var/www/html/

vi index.php

Paste the following into the file


Close the file,


Now that the file is written let's restart Apache

apachectl restart

Everything is installed you can now go to


And you will see a page like:


There is a section in the php info file you created Loaded Configuration File


This is the ini file used for your installation of PHP.

Editing PHP.ini

The configuration file (php.ini) is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started.

  1. cd /etc/php5/apache2
  2. vi php.ini

Enable logging, uncomment the following:

;error_log = php_errors.log

Ensure that

short_open_tag = Off

Development should be

error_reporting = E_ALL

Production should be

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

Posted in
Last update:
2015-12-03 20:39
Average rating:0 (0 Votes)