How to install PHP on Ubuntu 14.04?


To get you started with installing PHP and Apache on VPS or Dedicated server running Ubuntu 14.04 OS use following command:


apt-get update && apt-get upgrade

apt-get install -y apache2

After this, you may verify that the Apache gets installed by opening the browser and going to link- http://your-ip-address

Now, that you’ve installed Apache, it’s time to install PHP with following command:

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


After that, you need to verify if everything works accurately, just create a PHP info file as given below:

cd /var/www/html/

vi index.php

Then, paste following command in the file:


Then close the file as below,


Now, since the file has been written, restart Apache

apachectl restart


Since installation is now complete, go to the following link:


And page as shown below will appear on screen:


A section will be created in the php info file as created by you- Loaded Configuration File

This is going to be the ini file used for your PHP installation.

Editing PHP.ini


Configuration file ‘php.ini’ is read after PHP is started. This occurs only once when web server is started for server module versions of PHP.

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

Activate logging and uncomment the following:

;error_log = php_errors.log

and make sure that: short_open_tag = Off

Development be: error_reporting = E_ALL

Production should be: error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT



Radhe Dhakad is Support Executive and Network Admin at RackBank Datacenters Pvt. Ltd.. He is our curious techie who loves experimenting on servers and likes to pen down whatever he explores new on server technology!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© Copyright 2013-2019 RackBank© Datacenters Private Ltd.

Data Center in India

Rated 4.7/5 based on 31 reviews at Google+