Home Ubuntu How to install and configure ownCloud on Ubuntu 18.04 LTS

How to install and configure ownCloud on Ubuntu 18.04 LTS

by Darshana
Published: Updated:
setup owncloud server on ubuntu

ownCloud is an open-source file sharing server and collaboration platform. It allows controlling data on users’ servers and environments. Once configured, ownCloud provides easy access to all your data – whenever you want, wherever you want.

ownCloud Features

  • Access everything wherever you want
  • Share with anybody on your terms
  • Mobile and Desktop Syncing
  • End-to-end encryption support
  • Extensible through an Agile App framework

ownCloud is free to download and install on your private servers without paying to service providers.

In this article, we will help you install and configure ownCloud on your Ubuntu machine. This tutorial is thoroughly tested on Ubuntu 18.04 LTS.

Install ownCloud on Ubuntu 18.04 LTS

Before setting up Owncloud, you need to install Apache, PHP, and MySQL.

Step 1 – Install Apache HTTP Server

Let’s start with updating the system repositories. Launch the Terminal and enter the following command:

sudo apt-get update

Install Apache:

sudo apt-get install apache2

Generally, the Apache service starts automatically. Check the status using the command:

sudo systemctl status apache2.service

If you see the service has not started, you can start it manually using the following command.

sudo systemctl start apache2

Enable Apache On system boot.

sudo systemctl enable apache2

Allow Apache ports from the Ubuntu Firewall.

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

Reload firewall and check the Firewall status.

sudo ufw reload
sudo ufw status

To check the Apache installation running status, launch the browser using hostname or server IP address.

http://hotname or IP/

If you see the Apache default page, it means everything went well.

Apache Default Page

Apache Default Page

Step 2 – Install MySQL

Let’s start with checking for available MySQL version.

sudo apt-cache policy mysql-server

As you see there is a new version available. We shall install using the command as follows:

sudo apt-get install mysql-server mysql-client

Securing MySQL installation

sudo mysql_secure_installation

You should see a prompt if you want to configure the VALIDATE PASSWORD PLUGIN. Type “Y” to yes and hit Enter to continue.

Then you should see a prompt to select a level of password validation. Select password strength and continue

Go ahead and provide a password for MySQL root user.

It should ask “Do you wish to continue with the password provided?”. Type “Y” and hit Enter.

You should see a series of questions — type “Y” for each one of them.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

By now you should have installed MySQL and also securely configured it. You can access MySQL server using the root login and password.

sudo mysql -u root -p
MySQL Root Login

MySQL Root Login

Step 3 – Install PHP

We should first check for available PHP versions and then install it.

sudo apt-cache policy php

Install PHP.

sudo apt-get install php php-cgi libapache2-mod-php php-common php-pear php-mbstring php-mysql php-curl php-json

Step 4 – Install ownCloud

You can add the repository key to apt.

sudo wget -nv https://download.owncloud.org/download/repositories/production/Ubuntu_18.04/Release.key -O Release.key
sudo apt-key add - < Release.key

Run the following shell commands to add the repository:

sudo echo 'deb http://download.owncloud.org/download/repositories/production/Ubuntu_18.04/ /' |  sudo tee /etc/apt/sources.list.d/owncloud.list

Update repositories.

sudo apt-get update

Install additional PHP packages.

sudo apt install php-bz2 php-curl php-gd php-imagick php-intl php-mbstring php-xml php-zip

Install ownCloud package.

sudo apt-get install owncloud-files
Install Owncloud Package

Install Owncloud Package

Generally, the ownCloud package we installed copies the web files to “/var/www/owncloud” on the server.

Step 5 – Configure Apache with SSL

Now we shall create a virtual host for ownCloud.

Create a folder for SSL certificates.

sudo mkdir /etc/apache2/ssl

Enable SSL module.

sudo a2enmod ssl

Restart Apache.

sudo systemctl restart apache2

Copy your SSL certificates to “/etc/apache2/ssl/ ” folder

Create a virtual host file.

sudo vim /etc/apache2/sites-available/fosslinuxowncloud.com.conf

Add the following lines to file. Replace ServerName with fosslinuxowncloud with whatever you want.

<VirtualHost *:80>
    ServerName fosslinuxowncloud.com
    ServerAlias www.fosslinuxowncloud.com
    ServerAdmin webmaster@fosslinuxowncloud.com
    DocumentRoot /var/www/owncloud

<Directory /var/www/owncloud>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/fosslinuxowncloud.com-error.log
    CustomLog ${APACHE_LOG_DIR}/fosslinuxowncloud.com-access.log combined
</VirtualHost>

<VirtualHost *:443>
    ServerName fosslinuxowncloud.com
    ServerAlias www.fosslinuxowncloud.com
    ServerAdmin webmaster@fosslinuxowncloud.com
    DocumentRoot /var/www/owncloud

<Directory /var/www/owncloud>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/fosslinuxowncloud.com-ssl-error.log
    CustomLog ${APACHE_LOG_DIR}/fosslinuxowncloud.com-ssl-access.log combined


SSLEngine on

SSLCertificateFile /etc/apache2/ssl/fosslinuxowncloud.cer
SSLCertificateKeyFile /etc/apache2/ssl/fosslinuxowncloud.key
SSLCertificateChainFile /etc/apache2/ssl/fosslinuxowncloud.ca


</VirtualHost>

You can give whatever name to your SSL certificate files.

SSLCertificateFile /etc/apache2/ssl/certificatefile-name.cer
SSLCertificateKeyFile /etc/apache2/ssl/certificate-key-name.key
SSLCertificateChainFile /etc/apache2/ssl/chain-certificate-name.ca

Check the syntax of the configuration file.

sudo apachectl -t

If you get a “Syntax OK” message, use this command line to disable the default, virtual host.

sudo a2dissite 000-default.conf

The following commands should enable new virtual hosts.

sudo a2ensite fosslinuxowncloud.com.conf

Restart Apache to activate changes.

sudo systemctl restart apache2

Step 6 – Configuring the MySQL Database for Owncloud

Access MySQL using the root account.

sudo mysql -u root -p

Create a database, and name it as you want.

create database fosslinuxowncloud;

Create a DB user and grant privileges.

create user 'ownclouduser'@'localhost' identified BY 'QB35JaFV6A9=BJRiT90';
grant all privileges on fosslinuxowncloud.* to ownclouduser@localhost;

Flush privileges.

flush privileges;

Step 7 – Configure ownCloud

Open a web browser and navigate to the following address to access the ownCloud web interface.

https://Domain-Name or IP
Owncloud Web Interface

Owncloud Web Interface

Create an admin account by choosing a username and a password. No need to modify Data Folder.

Fill out the details of the database name, database username, and database password. Here we installed the database in the same server, so we leave the database host as “localhost”.

Configurations

Configurations

Click the “Finish setup” button to finish configuring.

Now it should redirect to login page. You can provide given username and password to access the dashboard.

Login Page

Login Page

Inside Owncloud

Inside Owncloud

You can use a desktop or mobile client to sync your data to your ownCloud. Download OwnCloud client from here.

Owncloud-Files-and-Folders

Owncloud-Files-and-Folders

Step 8 – Install Owncloud client on Ubuntu 18.04 Desktop

Run following commands to add the repository. We should run commands as root user.

wget -nv https://download.opensuse.org/repositories/isv:ownCloud:desktop/Ubuntu_18.04/Release.key -O Release.key
apt-key add - < Release.key

Update repository.

apt-get update

Add repository.

sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/Ubuntu_18.04/ /' > /etc/apt/sources.list.d/isv:ownCloud:desktop.list"

Update repository.

apt-get update

Install client.

apt-get install owncloud-client

After installation is complete, open ownCloud desktop Sync client, add your Domain name and click next.

Open-Owncloud-Client

Open-Owncloud-Client

Then you should get User credentials window where you should provide your username and password.

User Credentials

User Credentials

Then you can select the local folder and configure sync settings.

Owncloud-Local-Folder-Options

Owncloud-Local-Folder-Options

After you click connect, it should sync data with the server.

Data-Sync

Data-Sync

Synchronizing-Completed

Synchronizing-Completed

You can add your files to the ownCloud local folder. For example, I have added an image to the folder.

Added-Image

Added-Image

Then it should sync to the server.

Now you can go to the server and check the data. You can see the added image on the server.

Added-File-On-Server

Added-File-On-Server

If you have come this far, you successfully installed and configured the ownCloud server and also synced files with its desktop client.

How did your installation go? Let us know your feedback in the comments below, and don’t forget to share this article with your friends and colleagues who may find it useful.

You may also like

11 comments

xerox2@wanadoo.fr April 18, 2019 - 2:56 AM

did not work forme mint 19.1 32 bit machine perhaps this is the problem 32 bit

Reply
Tony Coutts June 14, 2019 - 8:58 PM

Great article, Darshana! Thank you.

Reply
Mike McGuffie August 27, 2019 - 5:33 AM

Hi there,
I’m missing as to where the SSL certificates I am to copy to the created folder are.
“Copy your SSL certificates to “/etc/apache2/ssl/ ” folder”
Thanks,
McG

Reply
Charles Barnes September 2, 2019 - 4:47 PM

I’m having the same trouble as Mike McGuffie. Where do we find these certificates of which you speak?

Reply
Sunny Song November 28, 2019 - 2:02 AM

Same issue as per Mike McGuffle is facing.

Reply
Pong Songpongs January 3, 2020 - 1:59 AM

For certificates, you can buy them from a trusted company or generate your own files.

To generate your own, use the command:

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/apache2/ssl/MyOwnCloud.key -out /etc/apache2/ssl/MyOwnCloud.cer

The command will give you a 10 years (3650 days) validity. Along with site information you provided during the execution.

Also, please change the name of the certificate files and comment out the chain file.

SSLCertificateFile /etc/apache2/ssl/MyOwnCloud.cer
SSLCertificateKeyFile /etc/apache2/ssl/MyOwnCloud.key
#SSLCertificateChainFile /etc/apache2/ssl/fosslinuxowncloud.ca

This will enable your SSL connection but your browser will notify you that you are not secure. It is because this is a self-signed keys hence there is no one to verify it. But the connection will be encryped securely.

Reply
tomy January 13, 2020 - 7:29 AM

Thank you.

Reply
vetle April 2, 2020 - 8:25 AM

When I try the website.. I get a huge error message, and says something along the lines of; “owncloud not supported by microsoft windows” and “This version of ownCloud requires at least PHP 7.1.0 “.
How can I fix this?

Reply
David Novak May 12, 2020 - 1:52 PM

i have same issue

Reply
Milan August 23, 2020 - 6:17 PM

Pong Songpongs you’re a life saver!
You forgot to add xxxxx.ca file to you command. I’ve retyped with this command and added the 3rd missing file.
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/apache2/ssl/MyOwnCloud.ca

Big thanks to everyone involved!

Reply
‪doron Pinsky‬‏ August 29, 2020 - 2:09 AM

Thanks a lot for the tutorial. I did not understand how to access to my owncloud outside the local network, I want to have access from WAN.

Reply

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.