Install OwnCloud on Ubuntu 18.04 LTS with Apache2, MariaDB and PHP 7.1

I recently installed Ubuntu 18.04 LTS on a mini PC, I decided why don’t we install OwnCloud and use this mini PC as a free cloud storage server. Here are the steps I took that shows how I got OwnCloud installed on Ubuntu.

OwnCloud is free robust open source software that allows you to set up your own cloud syncing, like Dropbox and Onedrive cloud storage, and other cloud storage services out there, unlike the other cloud storage services, OwnCloud is free to use.

This tutorial shows everyone the necessary steps to install and configure OwnCloud on Ubuntu 18.04 LTS Desktop in your home environment.

To get started with installing OwnCloud, follow the steps below:

Install Apache2 HTTP Server

Install Apache2 on Ubuntu by running the following commands:

sudo apt install apache2

After installing Apache2, run the commands below to disable directory listing.

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/apache2/apache2.conf

After install Apache2, the commands below can be used to stop, start and enable Apache2 service to always start up with the server boots.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

Install PHP and Related Modules

Run the commands below to add a third party repository and upgrade to PHP 7.1

sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php

Then update and upgrade to PHP 7.1

sudo apt update

Run the commands below to install PHP 7.1 and related modules..

sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common php7.1-mbstring php7.1-xmlrpc php7.1-soap php7.1-apcu php7.1-smbclient php7.1-ldap php7.1-redis php7.1-gd php7.1-xml php7.1-intl php7.1-json php7.1-imagick php7.1-mysql php7.1-cli php7.1-mcrypt php7.1-ldap php7.1-zip php7.1-curl -y

After install PHP 7.1, run the commands below to open FPM PHP default file.

sudo nano /etc/php/7.1/apache2/php.ini

Then make the change the following lines below in the file and save.

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_filesize = 100M
display_errors = Off
date.timezone = America/Florida

Create OwnCloud Database

Now that you’ve install all the required packages, continue to start configuring the server.

To connect to MariaDB server, run the commands below.

sudo mysql -u root -p

Then create a database called owncloud


Create a database user called ownclouduser with new password

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

Then grant the user full access to the database.

GRANT ALL ON owncloud.* TO 'ownclouduser'@'localhost' IDENTIFIED BY 'password_here' WITH GRANT OPTION;

Now, save your changes and exit.


Download Latest OwnCloud Release

Download and and extract OwnCloud files into its root directory:

cd /tmp && wget
sudo mv owncloud /var/www/html/owncloud/

Then run the commands below to set the correct permissions for OwnCloud to function.

sudo chown -R www-data:www-data /var/www/html/owncloud/
sudo chmod -R 755 /var/www/html/owncloud/

Configure Apache2

Configure Apahce2 site configuration file for OwnCloud. This file will control how users access OwnCloud content. Run the commands below to create a new configuration file called owncloud.conf

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

Then copy and paste the content below into the file and save it. Replace the highlighted in red lines with your own domain name and directory root location.

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/owncloud/
     Alias /owncloud "/var/www/html/owncloud/"

     <Directory /var/www/html/owncloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
        SetEnv HOME /var/www/html/owncloud
        SetEnv HTTP_HOME /var/www/html/owncloud

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined


Save the file and exit.

Enable the OwnCloud and Rewrite Module

After configuring the VirtualHost above, enable it by running the commands below

sudo a2ensite owncloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

Restart Apache2

To load all the settings above, restart Apache2 by running the commands below.

sudo systemctl restart apache2.service

Access Owncloud from the LAN

To access ownCloud from inside the network, We need to know the IP address of the owncloud server and use it to access it by placing it in the search bar as follows:

1. Open the terminal and enter the following command:


2. Locate the IP address of the Ubuntu server, it should look something like: 192.x.x.x or 10.x.x.x

3. Place your LAN IP in the address bar like this:


4. You should then see OwnCloud setup page. You’ll be prompted to create admin account and password. Connect to the database using the information you created and continue.

If you left it default then it should look like the image below:

Click on Finish setup to finish installing Owncloud on Ubuntu 18.04 LTS

Enable SSL for Secure External Access

This process only applies if you are planning on connecting to the ownCloud from the WAN (outside the network) using mobile devices or tablet. Enable and configure SSL on Owncloud:

1. Open the terminal and run the following command:

sudo a2enmod ssl

2. Create a new directory for the self signed certificate:

sudo mkdir /etc/apache2/ssl

3. Create the self signed certificate and the server key that protects it, and placing both of them into the new directory:

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

Note: The above certificate is valid for 365 days. We have mentioned validity days in the command.

4. Now we need to setup the certificate:

sudo nano /etc/apache2/sites-available/default-ssl­.conf

5. The lines that need changing are the following:

ServerName IP :443
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/owncloud.crt
SSLCertificateKeyFile /etc/apache2/ssl/owncloud.key


6. Activate the new virtual host

sudo a2ensite default-ssl

7. Restart apache

sudo service apache2 restart

Port Forward for External Access

Log into your router and get the WAN IP address:


Now we need to add the WAN IP to your trusted IP list and not to be overwritten by ownCloud. To do this open the Owncloud config file, enter:

sudo nano /var/www/html/owncloud/config/config.php

Here add the WAN IP (External IP address) you just got from the router to the trusted domains array. Your new entry should look something like this:

1 => '',

X are just placeholders. Replace the X’s with the WAN IP Address.

Now update the URL of the overwrite.cli.url line with your WAN IP Address. It should look something like this:

‘overwrite.cli.url’ => ‘’,

Here is an example of the completed config.txt file.


Hidden is the WAN IP. Once done save and exit.

Log back into your router and navigate to the port forward section.


Now port forward SSL port 443 to the Ubuntu server runnung ownCloud instance internal IP (LAN IP) address and save settings.


Now your ownCloud is ready to be accessed externally (WAN) and from your devices just download the ownCloud App and enter: “https:// WAN IP Address” on the address bar or devices. below is an example:


Basic First Access Setup

This applies in case you did not set it up from the LAN previously.

1. Accessing your ownCloud from outside the network: open your browser and enter the WAN IP address. i.e. “” you’ll be directed to your ownCloud storage server.

2. Accessing ownCloud From inside the network: open your browser and enter the Ubuntu IP address provided, in my case is “” you’ll be directed to your ownCloud storage server.

3. Because we installed SSL for more security you might get a certificate error, simply add the certificate to your exception list to proceed


4. You should be presented with a simple setup screen, Here enter a username and password to create an admin account. Click Finish setup.


I started this tech blog back in 2011 as a place to write down processes I took to fix my client systems and network. Now I write some tips and tricks to help others with the tech issues that one might encounter.

You may also like...

5 Responses

  1. budu kelateey says:

    Thanks . can you make a toturial for connecting to the ownCloud from the WAN (outside the network)

  2. luki says:

    Great tip , thank you !

  3. Serz says:

    Nice job! Respect!!!

  4. VonKairak says:

    Muchas Gracias, excelente explicación.