Install ownCloud on Ubuntu 14.04 LTS

Install ownCloud on Ubuntu 14.04 LTS

Install ownCloud on Ubuntu 14.04 LTS

Firstly this step-by-step guide will help you install ownCloud on Ubuntu 14.04 LTS and should also work on 12.04.

With all the iCloud security problems lately, most people don’t feel they can trust their content is safe in the cloud. There’s a solution to that… host your own cloud using ownCloud. ownCloud has clients for your laptop and smartphone which will sync your data over Wifi or if you’re brave enough and have time to fight with services like DynDNS you could make it available anywhere, but we’re not going into that option in this post. Think of it as your own private DropBox.

I’ll be working as root just to avoid having to change user accounts all the time and not having to type sudo for almost every line.
First we need a PPA for PHP5, press Enter when prompted to do so:

root@owncloud01:~$ add-apt-repository ppa:ondrej/php5
This branch follows latest PHP packages as maintained by me & rest of the Debian pkg-php team.

You can get more information about the packages at

If you need to stay with PHP 5.4 you can use the oldstable PHP repository:

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:
More info:
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmp45via5h6/secring.gpg' created
gpg: keyring `/tmp/tmp45via5h6/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server
gpg: /tmp/tmp45via5h6/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)

Run the apt-get updates to ensure we install the latest packages.

root@owncloud01:~# apt-get update

Install PHP5

root@owncloud01:~# apt-get install php5

Now we need to install a few more packages that are needed to run ownCloud.

root@owncloud01:~# apt-get install apache2 mysql-server libapache2-mod-php5

You will be taken through the MySQL Server configuration tool, so make sure you use a password that you will remember and also write it down so you avoid unnecessary problems later, then eat it because it’s your MySQL server root password!
More packages to install.

root@owncloud01:~# apt-get install php5-gd php5-json php5-mysql php5-curl

Some more…

root@owncloud01:~# apt-get install php5-intl php5-mcrypt php5-imagick

At the time of writing the following link was the latest version. If that doesn’t work you can go here and click the Archive for server owners button. Right click the Unix link and copy the link location.
Now back to your server for downloading the file

root@owncloud01:~# wget

The file is around 30MB so it wont take too long to download, depending on your internet connection of course.
Now we can untar the files and install the package. It will create the directory called owncloud.
Copy this directory to the Apache webserver root document. This does place ownCloud in a sub-directory though.

root@owncloud01:~# cp -r owncloud /var/www/

Now we need to change the ownership over the directory that we just copied

root@owncloud01:~# chown -R www-data:www-data /var/www/owncloud/

In order to secure the web directory do the following.

root@owncloud01:~# find /var/www/owncloud/ -type d -exec chmod 750 {} \;
root@owncloud01:~# find /var/www/owncloud/ -type f -exec chmod 640 {} \;

ownCloud recommends using SSL when connecting to the ownCloud service. It’s not really necessary if you’re going to be using it at home only but for safety sake let’s just enable SSL. If you’re using this setup for an office environment then you will want to use SSL.

root@owncloud01:~# sudo a2enmod ssl
root@owncloud01:~# a2ensite owncloud
root@owncloud01:~# service apache2 reload

Check which version of Apache you are running

root@owncloud01:~# apache -v
root@owncloud01:~# apache2 -v 
Server version: Apache/2.4.10 (Ubuntu) 
Server built: Jul 22 2014 22:49:37

**NOTE: you will need to create a SSL certificate for the following to work securely** – This post will explain how
Now we need to add a few lines to the Apache config, depending on your version you’ll use different code.
For Apache 2.2 we use:

<Directory /path/to/your/owncloud/install>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all

For Apache 2.4

<Directory /path/to/your/owncloud/install>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted

In my case it’s Apache 2.4
So my Apache config would look like this, located at /etc/apache2/sites-available/owncloud.conf

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
        ServerName owncloud01
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/owncloud
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        <Directory /var/www/owncloud>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
        SSLEngine on
        SSLCertificateFile    /etc/apache2/ssl/self-signed.crt
        SSLCertificateKeyFile /etc/apache2/ssl/self-signed.key
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        BrowserMatch "MSIE [2-6]" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
        <Directory /var/www/owncloud>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
                # add any possibly required additional directives here
                # e.g. the Satisfy directive (see below for details):
                Satisfy Any

For ownCloud to work properly you need the module mod_rewrite. So enable it by running:

root@owncloud01:~# a2enmod rewrite

Remove the following links in /etc/apache2/sites-enabled (if they exist)

root@owncloud01:~# rm /etc/apache2/sites-enabled/rm 000-default.conf default-ssl.conf

Edit the php.ini file

root@owncloud01:~# vi /etc/php5/apache2/php.ini

Look for the following and change it to look like mine

session.save_path = "/var/lib/php5/sessions"

We need to make sure that those folders are accessible to apache.

root@owncloud01:~# chown www-data:www-data /var/lib/php5/sessions

Finally restart apache

root@owncloud01:~# /etc/init.d/apache2 restart

Open your browser and go to https://yourservername/
You will be prompted to create an admin username and password, also that root MySQL username and password.

If you skip the editing of the php.ini part you will end up with an error after trying to login for the first time, that looks something like this:
"{"data":{"message":"Token expired. Please reload page.","error":"token_expired"},"status":"error"}"

11 thoughts on “Install ownCloud on Ubuntu 14.04 LTS

  1. Pingback: ownCloud on Trusty | 0ddn1x: tricks with *nix

  2. Andrew

    I have tried and failed several times to install an owncloud server on my Ubuntu 14.04 machine. Before I try these instructions, may I inquire: will they work on a regular 14.04 install? I am not running a sever, just a regular machine that I would like to use to host my own cloud so I don;t have to use DropBox. I am a novice on Ubuntu (at best…). Thanks for your posted instructions, whether they work for me or not, I find them clear. I will try an install later this week.

  3. Brian

    Lyle — Thank you for putting together this step-by-step guide. I’m a complete Linux beginner and this has been very helpful overall.

    I’m trying to restart Apache after doing the ssl steps by I am now greeted with “Syntax error on line 219 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/sites-enabled/default-ssl.conf: No such file or directory
    Action ‘configtest’ failed.”

    Any suggestions?

  4. Stephan


    Your owncloud.conf file is broke.

    “<FilesMatch "\.(cgi|shtml|phtml|php)$"%gt;"
    needs to be

    “&ltDirectory /var/www/owncloud&gt”
    needs to be

    I believe this is where some of the users are having difficulties on.


    1. Stephan

      Well, it seems your WordPress site does not want to post the correct information, probably the reason your original config file is displaying wrong.

Leave a Reply

Your email address will not be published. Required fields are marked *