Read in 4 minutes

last updated 

How To Install and Configure ownCloud with Apache on Ubuntu 18.04

ownCloud is an open source, self-hosted file sync and file share platform, similar to Dropbox, Microsoft OneDrive and Google Drive. ownCloud is extensible via apps and has desktop and mobile clients for all major platforms.

In this tutorial we’ll show you how to install and configure ownCloud with Apache on an Ubuntu 18.04 machine.

Prerequisites

You’ll need to be logged in as a user with sudo access to be able to install packages and configure system services.

Step 1: Creating MySQL Database

ownCloud can use SQLite, Oracle 11g, PostgreSQL or MySQL database to store all its data. In this tutorial we will use MySQL as a database back-end.

If MySQL or MariaDB is not installed on your Ubuntu server you can install by following one of the guides below:

Start by login in to the MySQL shell by typing the following command:

sudo mysql

From within the MySQL shell, run the following SQL statement to create a database:

CREATE DATABASE owncloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Next, create a MySQL user account and grant access to the database:

GRANT ALL ON owncloud.* TO 'owncloudsuser'@'localhost' IDENTIFIED BY 'change-with-strong-password';

Finally, exit the mysql console by typing:

EXIT;

Step 2: Installing PHP and Apache

ownCloud is a PHP application. PHP 7.2 which is the default PHP in Ubuntu 18.04 is fully supported and recommended for ownCloud.

Install Apache and all required PHP extensions using the following command:

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

Step 3: Configuring Firewall

Assuming you are using UFW to manage your firewall, you’ll need to open HTTP (80) and HTTPS (443) ports. You can do that by enabling the ‘Apache Full’ profile which includes rules for both ports:

sudo ufw allow 'Apache Full'

Step 4: Downloading ownCloud

At the time of writing this article, the latest stable version of ownCloud is version 10.0.10. Before continuing with the next step visit the ownCloud download page and check if there is a new version of ownCloud available.

Use the following wget command to download the ownCloud zip archive:

wget https://download.owncloud.org/community/owncloud-10.0.10.zip -P /tmp

Once the download is complete, extract the archive to the /var/www directory:

sudo unzip /tmp/owncloud-10.0.10.zip  -d /var/www

Set the correct ownership so that the Apache web server can have full access to the ownCloud’s files and directories.

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

Step 5: Configuring Apache

Open your text editor and create the following Apache configuration file.

sudo nano /etc/apache2/conf-available/owncloud.conf
/etc/apache2/conf-available/owncloud.conf
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>

Enable the newly added configuration and all required Apache modules with:

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

Activate the changes by restarting Apache service:

sudo systemctl reload apache2

Step 6: Installing ownCloud

Now that ownCloud is downloaded and all necessary services are configured open you browser and start the ownCloud installation by visiting your server’s domain name or IP address followed by /owncloud :

http://domain_name_or_ip_address/owncloud

You will be presented with the ownCloud setup page.

Enter your desired admin username and password and the MySQL user and database details you previously created.

Click on the Finish setup button and once the installation process is completed you will be redirected to the ownCloud dashboard logged in as admin user.

Conclusion

You have learned how to install and configure ownCloud on your Ubuntu 18.04 machine. If you have a domain name associated with your ownCloud server, you can follow this guide and secure your Apache with Let’s Encrypt.

To find more information about how to manage your ownCloud instance visit the ownCloud documentation page.

If you have any question, please leave a comment below.