Installing Ubuntu 14.04 LTS Server with PHP 5.6

Written by Mark Chambers on November 11, 2016


  1. Download and install Ubuntu
  2. Set system clock
  3. Upgrade to PHP 5.6
  4. Activate root user

1: Download and Install Ubuntu

1.1: Download

Pick your breed of “Trusty Tahr” below. I’ll be going with the 64-bit Server for this guide.

1.2: Install

Load your CD (or mount the ISO) to begin the installer.

Follow the prompts; here’s the process step-by-step:

  1. In the main menu, select "Install Ubuntu Server" and press Enter.
  2. Select a language – This is only for the install process. (This guide is in English, so...)
  3. Select your location – Since I'm in Germany, I have to choose other and press Enter...
  4. ...then I select Europe, then Germany.
  5. Configure locales – Because English and Germany isn't a valid combination, I have to choose a country to base my language settings on. I'll go with United States. ;)
  6. Configure the keyboard – Detect keyboard layout? Yes.
  7. Answer the Yes or No questions about which keys exist on your keyboard. Eventually it has enough information to make a good guess. Press Continue. If it seems wrong, Go Back and try again.
  8. Hardware detection and configuration will now take place. "This may take some time."
  9. Configure the network – Set the hostname to whatever is appropriate for your network. If you're not sure, just leave the default value and press Enter. For this example it’s bornkamp.
  10. Set up users and passwords – Enter full name of the user. For this example it’s going to be Bornkamp Dev.
  11. Enter a username for the above user. (This is typically a short-form of the above, in lower-case letters.) For this example it’s simply dev.
  12. Choose a password and verify it.
  13. Encrypt your home directory? Since I'm running a server and not really using the home directory, it's not necessary. So, No.
  14. Configure the clock – If it successfully detects your time zone, then press Enter. Otherwise press No and choose it manually.
  15. Now disk detection takes place...
  16. Partition disks – Choose partitioning method. For my case I'm choosing the first option: Guided – use entire disk.
  17. Now select the disk to partition and press Enter.
  18. Confirm that this is the right disk and that you acknowledge any contents will be deleted and replaced with Ubuntu. Write the changes to disks? Yes.
  19. Configure the package manager – Before we can install additional packages, we need Internet access. Do you gain access through a proxy? Not in this tutorial. Blank for none. Continue.
  20. Configuring apt... please wait.
  21. Configuring tasksel – No automatic updates
  22. Software selection – Select extra packages. Use the arrow keys to move up and down and press the spacebar to select a package. For this example we need OpenSSH server and LAMP Server. Press Enter to continue.
  23. Configuring mysql-server-5.5 – Choose a password for the MySQL "root" user. You can also leave it blank for none.
  24. The rest of the packages and their dependencies will now install...
  25. Install the GRUB boot loader on a hard disk – Yes
  26. This concludes the installation. Eject the CD (or unmount your ISO) and press Continue to reboot.

Log in as the user account you just created.

By default the root user account is disabled in Ubuntu. As unlocking it is not recommended, this guide will use the usual sudo-prepended commands.

2: Set System Clock

Before we start making changes to the server, let’s make sure the clock keeps in sync.

2.1: Enable built-in Network Time Protocol

timedatectl set-ntp true

2.2: Install the NTP daemon

sudo apt-get -y install ntp

2.3: Configure the NTP Servers

Once the program is installed, open the configuration file:

sudo vi /etc/ntp.conf

Find the selection below:


Since I'm in Germany, I'm going to replace it with these servers:


For a full list of NTP servers around the world, click here.

2.4: Restart and check the time

sudo service ntp restart


Output looks good:

      Local time: Wed 2016-11-30 13:49:36 CET
  Universal time: Wed 2016-11-30 12:49:36 UTC
        Timezone: Europe/Berlin (CET, +0100)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: no
 Last DST change: DST ended at
                  Sun 2016-10-30 02:59:59 CEST
                  Sun 2016-10-30 02:00:00 CET
 Next DST change: DST begins (the clock jumps one hour forward) at
                  Sun 2017-03-26 01:59:59 CET
                  Sun 2017-03-26 03:00:00 CEST

Now our log file timestamps will always be accurate. =]

3: Upgrade to PHP 5.6

3.1: Add the repository

sudo add-apt-repository ppa:ondrej/php

You should get the output:

Co-installable PHP versions: PHP 5.5, 5.6, PHP 7.0 and batteries included.

You can get more information about the packages at

For PHP 5.4 on Ubuntu 12.04 use: ppa:ondrej/php5-oldstable

BUGS&FEATURES: This PPA now has a issue tracker:

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly:

WARNING: add-apt-repository is broken with non-UTF-8 locales, see for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info:
Press [ENTER] to continue or ctrl-c to cancel adding it

Press Enter to continue.

3.2: Get PHP 5.6

Now run the following commands:

sudo apt-get update

sudo apt-get -y install php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysqlnd php5.6-xml php5.6-gd php5.6-dev make

3.3: Out with the old and in with the new

Disable PHP 5.5:

sudo a2dismod php5

Remove PHP 5.5:

sudo apt-get -y purge php5-common

Now enable 5.6:

sudo a2enmod php5.6

Now restart the server:

sudo service apache2 restart

3.4: Check the current version of PHP

php -v

If you see PHP 5.6.x... then you did something right!

4: Activate the root user

By default Ubuntu disables the superuser root in favor of privileged commands needing to be run with sudo, which then requires a password confirmation — good for preventing accidents. But if you’re fearless, rushed or just plain lazy, we can set root free like so:

sudo passwd root

First you are asked for your current user password, then you can choose (and confirm) the root password.

Now go ahead and change to root:

su root

Don’t break anything!

Enable root login over SSH

As root, edit the sshd_config file in /etc/ssh/sshd_config:

vi /etc/ssh/sshd_config

Add a line in the Authentication section of the file that says PermitRootLogin yes (if this line already exists with the value without-password, then replace with yes):

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

Save the updated /etc/ssh/sshd_config file.

Restart the SSH server:

service ssh restart

You can now connect to the server as root over SSH.