How to Install and Configure ownCloud with Apache on Ubuntu 18.04
3 min read
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.
You’ll need to be logged in as a user with sudo access to be able to install packages and configure system services.
Creating a MySQL Database
ownCloud can use SQLite, Oracle 11g, PostgreSQL and MySQL database to store all its configuration.
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 into the MySQL shell by typing the following command:
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 'ownclouduser'@'localhost' IDENTIFIED BY 'change-with-strong-password';
Finally, exit the mysql console by typing:
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
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'
At the time of writing this article, the latest stable version of ownCloud is version 10.3.2. 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.3.2.zip -P /tmp
Once the download is complete, extract the archive
sudo unzip /tmp/owncloud-10.3.2.zip -d /var/www
Set the correct ownership so that the Apache webserver 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
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 the necessary services are configured open your browser and start the ownCloud installation by visiting your server’s domain name or IP address followed by
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. Once the installation process is completed, you will be redirected to the ownCloud dashboard logged in as admin user.
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 should secure your Apache with a free Let’s Encrypt SSL certificate.
To find more information about how to manage your ownCloud instance, visit the ownCloud documentation page.
If you have any questions, please leave a comment below.