How to Install OwnCloud on Ubuntu 18.04

OwnCloud is a leading open-source file sharing and cloud collaboration platform whose services and functionalities are similar to those offered by DropBox and Google Drive. However, unlike Dropbox, OwnCloud does not have the datacenter capacity to store hosted files. Nevertheless, you can still share files such as documents, images, and videos to mention a few, and access them across multiple devices such as smartphones, tablets, and PCs.

In this article, you will learn how to install OwnCloud on Ubuntu 18.04 and newer versions.

Step 1: Update Ubuntu System Packages

Before getting started, update the system packages and repositories using the following apt command.

$ sudo apt update -y && sudo apt upgrade -y
Update Ubuntu System Packages
Update Ubuntu System Packages

Step 2: Install Apache and PHP 7.2 in Ubuntu

OwnCloud is built on PHP and is typically accessed via a web interface. For this reason, we are going to install the Apache webserver to serve Owncloud files as well as PHP 7.2 and additional PHP modules necessary for OwnCloud to function smoothly.

$ sudo apt install apache2 libapache2-mod-php7.2 openssl php-imagick php7.2-common php7.2-curl php7.2-gd php7.2-imap php7.2-intl php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-pgsql php-smbclient php-ssh2 php7.2-sqlite3 php7.2-xml php7.2-zip
Install Apache and PHP in Ubuntu
Install Apache and PHP in Ubuntu

Once the installation is complete you can verify if Apache is installed by running the dpkg command.

$ sudo dpkg -l apache2

From the output, we can see that we have installed Apache version 2.4.29.

Check Apache Version in Ubuntu
Check Apache Version in Ubuntu

To start and enable Apache to run on boot, run the commands.

$ sudo systemctl start apache2
$ sudo systemctl enable apache2

Now head over to your browser and type in your server’s IP address in the URL bar as shown:

http://server-IP

You should get a webpage below showing that Apache is installed and running.

Verify Apache Page in Ubuntu
Verify Apache Page in Ubuntu

To check if PHP is installed.

$ php -v
Check PHP Version in Ubuntu
Check PHP Version in Ubuntu

Step 3: Install MariaDB in Ubuntu

MariaDB is a popular open-source database server that is widely used by developers, database enthusiasts, and also in production environments. It’s a fork of MySQL and has been preferred to MySQL since the takeover of MySQL by Oracle.

To install the MariaDB run.

$ sudo apt install mariadb-server
Install MariaDB in Ubuntu
Install MariaDB in Ubuntu

By default, MariaDB is not secured and is prone to security breaches. We, therefore, need to perform additional steps to harden the MariaDB server.

To get started with securing your MySQL server, run the command:

$ sudo mysql_secure_installation

Hit ENTER when prompted for the root password and press ‘Y’ to set the root password.

Set MySQL Password in Ubuntu
Set MySQL Password in Ubuntu

For the remaining prompts, simply type ‘Y’ and hit ENTER.

Secure MySQL in Ubuntu
Secure MySQL in Ubuntu

Your MariaDB server is now secured to a decent level.

Step 4: Create an OwnCloud Database

We need to create a database for Owncloud to store files during and after installation. So log in to MariaDB.

$ sudo mysql -u root -p

Run the commands below:

MariaDB [(none)]> CREATE DATABASE owncloud_db;
MariaDB [(none)]> GRANT ALL ON owncloud_db.* TO 'owncloud_user'@'localhost' IDENTIFIED BY 'StrongP@ssword';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Create OwnCloud Database in Ubuntu
Create OwnCloud Database in Ubuntu

Step 5: Download OwnCloud in Ubuntu

After creating the database, now download the OwnCloud zipped file using the following wget command.

$ sudo wget https://download.owncloud.org/community/owncloud-10.4.0.zip

Once downloaded, unzip the zipped package to the /var/www/ directory.

$ sudo unzip owncloud-10.4.0.zip -d /var/www/

Then, set permissions.

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

Step 6: Configure Apache for OwnCloud

In this step, we are going to configure Apache to serve OwnCloud’s files. To do that, we are going to create a configuration file for Owncloud as shown.

$ sudo vim /etc/apache2/conf-available/owncloud.conf

Add the configuration below.

Alias /owncloud "/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>

Save and close the file.

Next, you need to enable all the required Apache modules and the newly added configuration by running the commands below:

$ sudo a2enconf owncloud
$ sudo a2enmod rewrite
$ sudo a2enmod headers
$ sudo a2enmod env
$ sudo a2enmod dir
$ sudo a2enmod mime

For the changes to come into effect restart the Apache webserver.

$ sudo systemctl restart apache2

Step 7: Finalizing the OwnCloud Installation in Ubuntu

With all the necessary configurations finalized, the only part remaining is to install OwnCloud on a browser. So head out to your browser and type in your server’s address followed by the /owncloud suffix.

http://server-IP/owncloud

You will be presented with a web page similar to the one below.

Create OwnCloud Admin Account
Create OwnCloud Admin Account

Just below, click on ‘Storage and database’. Select ‘MySQL / MariaDB’ under the ‘configure the database’ section and fill in the database credentials that you defined whilst creating the database for OwnCloud i.e database user, password of the database user, & database name.

Add OwnCloud Database Settings
Add OwnCloud Database Settings

Finally, click ‘Finish setup’ to wind up setting up Owncloud.

Finish OwnCloud Setup
Finish OwnCloud Setup

This takes you to the login screen as shown. Input the username and password defined earlier and hit ENTER.

OwnCloud Admin Login
OwnCloud Admin Login

A notification will be presented indicating other avenues that you can access OwnCloud from i.e iOS, Android & desktop App.

OwnCloud Supported Platforms
OwnCloud Supported Platforms

Close the pop-up to access the dashboard as shown:

OwnCloud Dashboard
OwnCloud Dashboard

And that’s it, guys! We have successfully installed the OwnCloud file sharing platform on Ubuntu 18.04.

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

12 thoughts on “How to Install OwnCloud on Ubuntu 18.04”

  1. I missed to take mysql/mariadb database and clicked on finish setup. Now how can change and from where I can change the database .

    Reply
  2. Hi I receive an error: ERROR 1064 (42000): You have an error in your SQL syntax; after the GRANT ALL ON owncloud_db.* TO ‘owncloud_user’@’localhost’ IDENTIFIED BY ‘StrongP@ssword’; command & I don’t know what is wrong, yes I Change the ‘StrongP@ssword’ by my password.

    Any tips for me

    Reply
  3. Can’t create or write into the data directory /var/www/owncloud/data.

    Can’t create or write into the apps-external directory /var/www/owncloud/apps-external.

    Reply
    • Hey Daaf, kindly ensure that you are using sudo in your commands. Also, ensure that you have the right permissions on the /var/www/owncloud directory.

      Reply
      • Please add one more step for giving permission.

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

        Thank you.

        Reply

Leave a Reply to James Kiarie Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.