How to install OwnCloud 10 server on Ubuntu

OwnCloud Ubuntu Logo

5OwnCloud is a Dropbox-like solution for self-hosted file sharing and syncing. Installing OwnCloud 10 on Ubuntu is trivial. Whether you want to backup, have file-syncing or just have a Google Calendar alternative, this guide is for you.

What is OwnCloud? Is it like a “cloud”?

If you stumbled here by chance and don’t know what OwnCloud is, here is an article explaining its principal features and advantages/disadvantages. In this other article you can find OwnCloud 10 new features. To tell you the truth, OwnCloud is a SaaS cloud, if you want to know more about cloud types you can read this article.

In this article we will cover the installation of the server (not the client).

Looking for an earlier version of this tutorial?

Step 1: Install OwnCloud

Important
I take absolutely NO responsibility of what you do with your machine; use this tutorial as a guide and remember you can possibly cause data loss if you touch things carelessly.

The first step is to add the repositories to your Ubuntu installation and install OwnCloud files. Although there are many packages available I suggest you to use the latest version of Ubuntu or an LTS version like Ubuntu 16.04 Xenial Xerus. You will need root access during this procedure. The following procedure will install apache as webserver. Input the commands one by one to avoid errors!

Ubuntu 16.04Ubuntu 16.10Ubuntu 17.04Future versions

Open a terminal and input the following commands:

# curl https://download.owncloud.org/download/repositories/10.0/Ubuntu_16.04/Release.key | apt-key add -
# sh -c "echo 'deb https://download.owncloud.org/download/repositories/10.0/Ubuntu_16.04/ /' > /etc/apt/sources.list.d/owncloud.list"
# apt-get update
# apt-get install owncloud-files
# apt-get install apache2 libapache2-mod-php7.0
# apt-get install php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring
# apt-get install php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip

Open a terminal and input the following commands:

# curl https://download.owncloud.org/download/repositories/10.0/Ubuntu_16.10/Release.key | apt-key add -
# sh -c "echo 'deb https://download.owncloud.org/download/repositories/10.0/Ubuntu_16.10/ /' > /etc/apt/sources.list.d/owncloud.list"
# apt-get update
# apt-get install owncloud-files
# apt-get install apache2 libapache2-mod-php7.0
# apt-get install php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring
# apt-get install php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip

Open a terminal and input the following commands:

# curl https://download.owncloud.org/download/repositories/10.0/Ubuntu_17.04/Release.key | apt-key add -
# sh -c "echo 'deb https://download.owncloud.org/download/repositories/10.0/Ubuntu_17.04/ /' > /etc/apt/sources.list.d/owncloud.list"
# apt-get update
# apt-get install owncloud-files
# apt-get install apache2 libapache2-mod-php7.0
# apt-get install php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring
# apt-get install php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip

For the foreseeable future OwnCloud will still be packaged for Ubuntu, so you just need to replace the VERSION with the future version (e.g. 19.10) in the following text and input the commands one by one:

# curl https://download.owncloud.org/download/repositories/10.0/Ubuntu_VERSION/Release.key | apt-key add -
# sh -c "echo 'deb https://download.owncloud.org/download/repositories/10.0/Ubuntu_VERSION/ /' > /etc/apt/sources.list.d/owncloud.list"
# apt-get update
# apt-get install owncloud-files
# apt-get install apache2 libapache2-mod-php7.0
# apt-get install php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring
# apt-get install php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip

These commands will add the repositories that contain the software and install it on your machine.

Step 2: Database selection

Now that you got the OwnCloud software, all that is left is to choose a database that will support the installation. You have three choices:

  • SQLite: is a single-file database. It is suggested only for small installations since it will slow OwnCloud down sensibly.
  • MariaDB/MySQL: are popular open source databases especially amongst web developers. It is the suggested choice.
  • PostgreSQL: a popular enterprise-class database. More complicated than MySQL/MariaDB.

Now, this choice won’t really alter the functionality of OwnCloud (except if you use SQLite), so pick whatever you know best. If you’re unsure pick MariaDB/MySQL.

SQLiteMySQL/MariaDBPostgreSQL

No additional steps are required if you choose SQLite.

Install the software:

# apt-get install mariadb-server

MariaDB won’t ask to set a root password (none by default), this is insecure, change it! In order to change it run the mysql_secure_installation script and follow the steps.

Or if you prefer MySQL:

# apt-get install mysql-server

During the installation you will be prompted to choose a root password, pick a strong one.

Now you need to enter the database (you will be asked the password you just set):

$ mysql -u root -p

Now that you are in create a database:

CREATE DATABASE owncloud;

Now you need to create the user that will be used to connect to the database:

CREATE USER 'oc_user'@'localhost' IDENTIFIED BY 'YOUR_PASSWORD_HERE';

The last step is to grant the privileges to the new user:

GRANT ALL PRIVILEGES ON owncloud.* TO 'oc_user'@'localhost';
FLUSH PRIVILEGES;

When you’re done type Ctrl-D to exit.

Install the software:

# apt-get install postgresql

Now you need to enter the database:

$ sudo -u postgres psql

Now that you are in create a database:

CREATE DATABASE owncloud;

Now you need to create the user that will be used to connect to the database:

CREATE USER oc_user WITH PASSWORD 'YOUR_PASSWORD_HERE';

The last step is to grant the privileges to the new user:

GRANT ALL PRIVILEGES ON DATABASE owncloud to oc_user;

When you’re done type \q and press enter to exit.

Step 3: Configuring Apache

In this step you will configure Apache, the web server.

Ubuntu 16.04

Now we need to create a new file in /etc/apache2/sites-available/owncloud.conf . Feel free to use whatever editor you feel comfortable with and add the following lines:

Alias /nextcloud "/var/www/owncloud/"

<Directory /var/www/owncloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/owncloud
 SetEnv HTTP_HOME /var/www/owncloud

</Directory>

Once done it’s time to enable the new site and enable apache mods that are needed by NextCloud:

# a2ensite owncloud
# a2enmod rewrite headers env dir mime
# systemctl restart apache2

Step 4: Configuring firewall

This step is essential when your firewall is enabled. If your firewall is enabled you won’t be able to access your OwnCloud 10 instance; on the other hand if it isn’t enabled you shouldn’t have any problems and you can simply skip this step. 

Tip!
Keep in mind having a firewall enabled is a good security practice and you should already have one enabled.

In order for the firewall to work, it must be enabled. This guide will not include this part. When you enable a firewall many things can go wrong, e.g. you’re using SSH, you enable the firewall and your connection is cut and can’t connect otherwise, hence you should carefully review the documentation from your distribution. Also, don’t forget opening ports can be a risk if your server is not configured properly.

To open the ports needed by OwnCloud 10 follow these steps:

UFWIPtables

UFW is the default firewall in Ubuntu, if you’re using one, you’re probably using UFW.

# ufw allow http
# ufw allow https

IPtables is an older firewall (still widely used), if you’re not using UFW you can use IPtables directly.

# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT

Step 5: Install

Once you’re done with selecting the database, it’s time to install everything. Head to http://YOUR_IP_ADDRESS/owncloud/ and you will be facing the following screen:

OwnCloud 10 installation

OwnCloud 10 installation

Select an administrator username and password, then you can select the data folder, but if you don’t know what you’re doing it’s best if you leave it with the default value. Then click on “Storage & Database” to select the database you chose during step 2. Fill everything and if you’ve followed all the steps correctly you should be seeing the Files app:

OwnCloud 10 Files App

OwnCloud 10 Files App

Image courtesy of mark | marksei
mark

You may also like...

6 Responses

  1. Daniel Zorro says:

    with the remotion of onwcloud package (for only the owncloud-files) this guide became obsolete

    • mark says:

      Hello Daniel, thank you very much for this insight! I will update this guide as soon as possible!

    • mark says:

      Hello again Daniel, as promised I have updated the guide to be compatible with the new repository! Please do take a look and tell me if it is working for you. Don’t hesitate to contact me whatever the issue : )

      • Daniel Zorro says:

        yeah the same that I did, anyway owncloud recommend nginx instead of apache buuut…. it’s easy just to install apache. As always thanks for this tutorial, very helpful :D

  2. da tra says:

    Hi,
    The problem is on the vhos file /etc/apache2/owncloud.conf
    Change nextcloud on owncloud
    savec close and restart
    sudo service apache2 reload

    If not working just take this:

    chown -R www-data:www-data /var/www/owncloud/
    and restart again the service
    sudo service apache2 reload

    Bgd

    • mark says:

      Hello da tra, I’m not exactly on what you mean with your comment. The tutorial is still working and there is no need to change permissions on the /var/www/owncloud folder since they are set by default.

Leave a Reply

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

%d bloggers like this: