Free collection of beautiful vector icons for your web pages.

How to install ownCloud server on Ubuntu 20.04

How to install ownCloud server on Ubuntu 20.04


This page explains how to install ownCLoud on Ubuntu 20.04. The following guide has been tested with the following versions:

First step, check that your system is up to date :

sudo apt update
sudo apt upgrade

After updating your system, reboot if necessary.

Install the LAMP stack

OwnCLoud needs a web server for first configuration and for the web interface. The simplest option is to install LAMP to get Apache, MySQL and PHP. Install the LAMP package:

sudo apt install lamp-server^ -y

Once the installation is completed, start and enable Apache service:

sudo systemctl start apache2
sudo systemctl enable apache2

At this stage, your Apache web server should be working. Check it in your browser by entering http://localhost in the url bar. You should get the following page:

Apache web server working before installing ownCloud

Install PHP

Install PHP and the required package with the following command:

sudo apt-get install php php-opcache php-gd php-curl php-mysqlnd php-intl php-json php-ldap php-mbstring php-mysqlnd php-xml php-zip -y

Restart Apache to enable changes:

sudo systemctl restart apache2


Start and enable the MySQL service:

sudo systemctl start mysql
sudo systemctl enable mysql

We strongly recommand to improve the security of the MySQL database with the following command: mysql_secure_installation:

sudo mysql_secure_installation

When prompt for the following, we recommend the following answers:

We now need to create the ownCLoud database from the MySQL console:

sudo mysql --user=root -p

Create the MySQL ownCloud database:


Create a new user. Replace password by the appropriate value:

CREATE USER 'ownclouduser'@'localhost' IDENTIFIED BY 'password';

Grant the new user with the necessary privileges:

GRANT ALL ON ownclouddb.* TO 'ownclouduser'@'localhost' WITH GRANT OPTION;

Enable changes by flushing the privileges:


Finally, exit the MySQL console:


Download ownCloud

Download the last ownCLoud version, 10.7.0 as the time of writing:


Unzip the downloaded file:


A new directory owncloud is created after unziping the file. Move the directory into the Apache default directory:

sudo mv owncloud /var/www/

Change the ownership of the directory for the user www-data:

sudo chown -R www-data: /var/www/owncloud

Create SSL certificate

Activate mod_ssl with the following command:

sudo a2enmod ssl

Restart Apache to enable changes:

sudo systemctl restart apache2

In order to get secured HTTPS access, let's create a SSL certificate:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/owncloud.key -out /etc/ssl/certs/owncloud.crt

Answer the questions. The last command should generate two files :

Configure Apache

Create and edit an Apache configuration file:

sudo gedit /etc/apache2/sites-available/owncloud.conf

or use nano if you are in command line:

sudo nano /etc/apache2/sites-available/owncloud.conf

Fill the text file with the following and adapt it to your needs:

<VirtualHost *:443>
    ServerName localhost
    DocumentRoot /var/www/owncloud

    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/owncloud.crt
    SSLCertificateKeyFile /etc/ssl/private/owncloud.key

Enable your new configuration file:

sudo a2ensite owncloud.conf

Enable the rewrite, mime, and unique_id Apache modules:

sudo a2enmod rewrite mime unique_id

Restart Apache to enable changes:

sudo systemctl restart apache2

In your brower, enter the url https://localhost, you should reach a page like the following:

SSL certificat enabled

Select advanced and proceed (you can trust this certificate since this is yours).

If you want an automatic redirection of http to https, edit the following file:

sudo gedit /etc/apache2/sites-available/000-default.conf

Add the following line in the file:

Redirect / localhost/

Configure ownCLoud

Once Apache, PHP, MySQl and ownCloud are installed, the last step is to set up ownCloud. This is done by the web interface. If everything is properly configured, you can access the ownCloud web interface at one of the following address:

The fist time you access the ownCloud web interface, you should get the first time configuration page. Let's detail each parameter:

Choose a user name and password for the main administrator account.

ownCloud first time configuration interface: admin account creation

Set the data folder. The user's files and folders stored in ownCloud will be stored here:

ownCloud first time configuration interface: set the data folder

The default value is /var/www/owncloud/data, but you can change according to your needs. If you select another folder, add the www-data user to the folder:

sudo chown -R www-data: /path/to/my/folder/

ownCloud first time configuration interface: set the database configuration

Connect ownCLoud to the MySQL database previously configured:

Click on Finish setup. You should be able to log in to your freshly installed ownCloud instance:

ownCloud web interface working

Remove default web server

If you do not use the web server, neuther redict HTTP to HTTPS, I recommand to remove the default HTML page. Edit the default page:

sudo gedit /var/www/html/index.html

Replace the content with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Access denied</title>
    <h1>HTTP Status 403 - Access is denied</h1>  </body>

When conneting to your server root directory, you should get something like:

Access denied to web server root directory

Last update : 05/07/2021