How to Install ownCloud on Ubuntu Linux with Apache

laptop 3361063 640
laptop 3361063 640

The content provides a thorough guide on how to install and configure ownCloud on Ubuntu Linux using Apache with Let’s Encrypt SSL. ownCloud, an open-source, self-hosted file sync, and share platform is introduced. Step-by-step instructions are given to install Apache, MariaDB, PHP on Ubuntu Linux and to configure Apache for ownCloud. It also explains how to download ownCloud, create an ownCloud database, and protect the server with Let’s Encrypt SSL certificates.

This post shows students and new users steps to install and configure ownCloud on Ubuntu Linux with Apache and Let’s Encrypt free SSL certificate.

ownCloud is an open-source, self-hosted file sync and share platform similar to Dropbox, OneDrive, and other proprietary online storage services. ownCloud enables private cloud services on users’ servers. It is extensible via its app and can be installed on mobile and desktops to access & sync your files, contacts, and data across all devices and platforms.

If you’re looking for a self-hosted file share and sync platform, ownCloud should be a good place to start. We’ll show you how to install and configure ownCloud on your own Ubuntu server with a link to the Let’s Encrypt SSL post.

Also, for students and new users learning Linux, Ubuntu Linux is the easiest place to start learning. Ubuntu is the modern, open-source Linux operating system for desktops, servers, and other devices.

Follow the steps below to start installing and configuring ownCloud on Ubuntu Linux.

How to install Apache on Ubuntu Linux

As mentioned above, we will use the Apache web server to run ownCloud. ownCloud requires a web server to function, and Apache is the most popular open-source web server available today.

To install Apache on Ubuntu, run the commands below:

sudo apt update
sudo apt install apache2

After installing Apache, the commands below can be used to stop, start and enable Apache services to start up every time your server starts up.

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

To test whether Apache is installed and functioning, open your web browser and browse to the server’s IP address or hostname.


Apache works as expected if you see the above page in your browser.

How to install MariaDB on Ubuntu Linux

A database server is required for ownCloud to function. ownCloud stores its content in a database, and MariaDB is probably the best database server available to run ownCloud.

MariaDB is fast, secure, and the default server for almost all Linux servers. To install MariaDB, run the commands below:

sudo apt install mariadb-server
sudo apt install mariadb-client

After installing MariaDB, the commands below can stop, start and enable MariaDB services to start up when the server boots.

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Next, run the commands below to secure the database server with a root password if you were not prompted to do so during the installation.

sudo mysql_secure_installation

When prompted, use the guide below to answer:

If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): PRESS ENTER

Switch to unix_socket authentication [Y/n] n

Change the root password? [Y/n] n

Remove anonymous users? [Y/n] y

Disallow root login remotely? [Y/n] y

Remove test database and access to it? [Y/n] y

Reload privilege tables now? [Y/n] y

All done!

To verify and validate that MariaDB is installed and working, log in to the database console using the commands below:

sudo mysql -u root -p

You should automatically be logged in to the database server since we initiated the login request as root. Only the root can log in without a password and from the server console.

mariadb welcome

The server was successfully installed if you see a similar screen.

How to install PHP on Ubuntu Linux

Also, PHP is required to run ownCloud. PHP packages are added to Ubuntu repositories. The versions of the repositories might not be the latest. If you need to install the latest versions, you’ll need to add a third-party PPA repository.

Run the commands below to a third-party repository with the latest versions of PHP.

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

At the time of this writing, the latest PHP version is 8.0.

sudo apt update

Next, run the commands below to install PHP 8.0 and related modules.

sudo apt install php7.4 libapache2-mod-php7.4 php7.4-imagick php7.4-common php7.4-mysql php7.4-gmp php7.4-imap php7.4-json php7.4-pgsql php7.4-ssh2 php7.4-sqlite3 php7.4-ldap php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip

Next, you’ll want to change some PHP configuration settings that work great with ownCloud. Run the commands below to open the PHP default configuration file.

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

Then change the line settings to be something like the lines below. Save your changes and exit.

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

How to create ownCloud database on Ubuntu

At this point, we’re ready to create our ownCloud database. As mentioned above, ownCloud uses databases to store its content.

To create a database for ownCloud, run the commands below:

sudo mysql -u root -p

Then create a database called owncloud


Next, create a database user called ownclouduser and set a password

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

Then grant the user full access to the database.

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

Finally, save your changes and exit.


How to download ownCloud on Ubuntu

We’re ready to download ownCloud and begin configuring it. First, run the commands below to download the latest version of ownCloud from its repository.

Next, extract the downloaded content into the Apache root directory. This will create a folder called owncloud.

wget -P /tmp
sudo unzip /tmp/ -d /var/www

Then run the command below to allow the www-data user to own the new owncloud directory.

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

How to configure Apache for ownCloud

We have downloaded ownCloud content into a new folder we called ownCloud. Let’s configure Apache to create a new server block with our ownCloud website. You can create as many server blocks with Apache.

To do that, run the commands below to create a new configuration file called owncloud.conf in the /etc/apache2/sites-available/ directory to host our ownCloud server block.

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

In the file, copy and paste the content below into the file and save.

Alias /owncloud "/var/www/owncloud/"

<Directory /var/www/owncloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off

 SetEnv HOME /var/www/owncloud
 SetEnv HTTP_HOME /var/www/owncloud


Save the file and exit.

After saving the file above, run the commands below to enable the new file that contains our ownCloud server block and other important Apache modules.

Restart Apache after that.

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

Reload Apache when the configuration is above.

sudo systemctl reload apache2

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 /own cloud :


However, we want to protect our server with Let’s Encrypt free SSL certificates. So, continue below to learn how to generate a Let’s Encrypt SSL certificate for websites.

How to setup Let’s Encrypt for ownCloud

We have written a great post on generating and managing Let’s Encrypt SSL certificates for Apache web servers. You can use that post to apply it here for your ownCloud website.

To read the post on how to generate Let’s Encrypt SSL certificates for a website, click on the link below:

How to Setup Let’s Encrypt on Ubuntu Linux with Apache – Website for Students

If you successfully generate a Let’s Encrypt SSL certificate, you should reopen the server block for our ownCloud website by running the commands below.

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

The new ownCloud server block configurations should look similar to the line below. Take notes of the highlighted lines.

  • The first server block listens on port 80. It contains a 301 redirect to redirect HTTP to HTTPS.
  • The second server block listens on port 443. It contains a 301 redirect to redirect www to the non-www domain.
<VirtualHost *:80>
  Redirect permanent /

<VirtualHost *:443>
  DocumentRoot /var/www

  Protocols h2 http:/1.1

  <If "%{HTTP_HOST} == ''">
    Redirect permanent /
  ErrorLog ${APACHE_LOG_DIR}/
  CustomLog ${APACHE_LOG_DIR}/ combined

  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/
  SSLCertificateKeyFile /etc/letsencrypt/live/
  SSLOpenSSLConfCmd DHParameters "/etc/ssl/certs/dhparam.pem"

  SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
  SSLCompression off
  SSLUseStapling on

  Header always set Strict-Transport-Security "max-age=63072000"

  Alias /owncloud "/var/www/owncloud/"

  <Directory /var/www/owncloud/>
    Options +FollowSymlinks
    AllowOverride All

    <IfModule mod_dav.c>
    Dav off

    SetEnv HOME /var/www/owncloud
    SetEnv HTTP_HOME /var/www/owncloud


Save the file above, then restart Apache and PHP using the commands below.

sudo systemctl reload apache2

Finally, if everything went as planned, you should be able to start the ownCloud setup wizard by browsing to the server hostname or IP address over HTTPS.

A download setup wizard should appear. Follow the wizard to complete the setup.

  • Create an admin account and password
  • leave Data folder default
  • Select MySQL/MariaDB
  • Enter the database username
  • Enter the database user password
  • Enter the database name
  • Leave database host as local host if ownCloud and database server are on the same host.

Click Finish setup

Wait for the setup to complete. Then log in and begin configuring your environment.

That should do it!


This post showed you how to set up ownCloud on Ubuntu Linux with Apache and Let’s Encrypt. Please use the comment form below if you find any errors above or have something to add.

Posted by

I love computers; maybe way too much. What I learned I try to share at

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.