ownCloud featured image

Install ownCloud on Debian 9 Linux Server

By

This tutorial is about the installation of latest ownCloud application with Let’s Encrypt Free SSL on a Debian 9 Server. The steps that I have mentioned will be the same for an Ubuntu VPS too. I will start from the very beginning and assume that you have a domain name for your ownCloud application and a VPS / droplet server ready to setup it.

Pre-requisites

  • A droplet / VPS server running in Debian 9 (x64) Linux Distribution (minimum 1GB RAM is recommended and 2GB+ RAM would be great).
  • Don’t you have a VPS server with your??
    Having a DigitalOcean droplet is same as having a VPS server. Sign up now via this link and redeem free $100 in credit over 60 days. Redeem Now !!
  • Root access to your server is essential.
  • A domain name to access your ownCloud: If you don’t have a domain name with you, you can do the installation / access ownCloud using the servers’ public IP.

Point you Domain to the VPS Server

Note: You can skip this step, if you are willing to access ownCloud with server’s public IP.

1. Login to your domain provider account and go to the page which allows you to manage DNS for you domain.
The DNS configuring interface will look something as follows (Example from Godaddy)

How a DNS manage panel looks

2. Next add following two records. If the records with same Type and Name are available, just change their values.

Record – 1
Type: A
Name: @ OR blank
Value / Target: YOUR-SERVER-IP_ADDRESS
TTL: 3600

Record – 2
Type: A
Name: www
Value / Target: YOUR-SERVER-IP_ADDRESS
TTL: 3600

DNS records example

3. Finally, save the changes.

4. Then you have to check whether your newly added DNS record has propagated successfully. For that;

  • Visit https://www.whatsmydns.net
  • Type your domain name, select the record type as and click on “Search”
  • If DNS records are not propagated successfully, you’ll get an output as follows (red – cross). Don’t worry, DNS would take about 2-3 hours (maximum 48 hours) to propagate and in the meantime we can consider on setting up our server.
  • If DNS records are propagated successfully, you’ll get an output as above (green -tick).

Connect to your VPS using a SSH Client

If necessary, you can follow my tutorial on “Make First Connection to your Droplet” or “Make First Connection to your VPS Server“.

Now we are ready to install ownCloud !

The installation procedure is consist of 7 sub-sections, let’s proceed ……

Install PHP and required PHP Modules

Issue following commands orderly to install PHP 7.2 and required PHP modules for ownCloud to operate.

sudo apt-get update

sudo apt-get install apt-transport-https

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -

sudo echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -rver.

sudo apt-get update
sudo apt-get install -y php7.2 php7.2-gd php7.2-curl php7.2-zip php7.2-dom php7.2-xml php7.2-simplexml php7.2-mbstring php7.2-mysql php7.2-intl

Note: If you get “-bash: sudo: command not found” issue, install it with

apt-get install -y sudo

Install a Web-Server (Apache)

sudo apt-get install -y apache2 libapache2-mod-php

sudo a2enmod ssl

sudo systemctl restart apache2

Some Apache Configurations

Note: You can skip this step, if you are willing to access ownCloud with server’s public IP.

Install nano text edition (if not already installed)

sudo apt-get install -y nano

Then let’s create a VirtualHost configuration file for your domain. Remember to replace yourdomain.com with your actual domain name.

cd /etc/apache2/sites-available
nano yourdomain.com.conf

Add following contents to the file

<VirtualHost *:80>
    ServerName yourdomain.com
    ServerAlias www.yourdomain.com
    DocumentRoot "/var/www/html/owncloud"
</VirtualHost>

Save and exit from the edition: CTRL + X, Then “y“, Then press Enter.

cd ../sites-enabled

ln -s ../sites-available/yourdomain.com.conf yourdomain.com.conf
sudo systemctl restart apache2

Install and Configure Let’s Encrypt SSL

Now we are going to install a Free SSL certificate for our domain, so that we can access ownCloud via HTTPS securely.

First add the certbot repository,

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

You’ll need to press ENTER to accept.

Then install certbot apache package:

sudo apt-get install -y python-certbot-apache

Then issue following command to have the SSL certificate installed. Replace yourdomain.com appropriately.

sudo certbot --apache -d yourdomain.com -d www.yourdomain.com

Since this is your first time running certbot, you will be prompted to enter an email address and agree to the terms of service.

agree to cerbot TOS

After obtaining the certificate, certbot will ask how you’d like to configure your HTTPS settings:

Redirect ownCloud to HTTPS

Select your choice 2 (Redirect) then hit ENTER

That’s it 🙂

Install & Secure MySQL database server

Issue following commands to install MySQL in your server.

wget http://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb

sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
Select the MYSQL Server version

Select “Ok” as in image and press Enter.

sudo apt-get update

sudo apt-get install -y mysql-server

The installation process will prompt for the root password to set as default. Input a secure password and same to confirm password window. This will be MySQL root user password required to log in to MySQL server.

Enter mysql root password
Confirm mysql root password

Then select the “Use Legacy Authentication Method” and press Enter.

Use Legacy Authentication Method

Now its time to secure the mysql installation.

sudo systemctl restart mysql

sudo mysql_secure_installation
Securing the MySQL server deployment.

Enter password for user root:
 (Enter your root password here)

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: N
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done!

Provide answers as above…..

Create MySQL database and user for ownCloud

Log in to mysql server as root user.

mysql -u root -p

Provide the root password.

Now let’s create a MySQL database and user account for configuring ownCloud. Give a strong password as “user_password

CREATE DATABASE owncloud;

CREATE USER 'owncloud'@'localhost' IDENTIFIED BY 'user_password';

GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud'@'localhost';

FLUSH PRIVILEGES;

exit;

Download and install the ownCloud

cd /var/www/html
rm index.html
wget https://download.owncloud.org/community/owncloud-complete-20200731.tar.bz2

Replace the download URL with the latest Tarball found at https://owncloud.com/download-server/

sudo tar xjf owncloud-complete-20200731.tar.bz2
sudo rm -f owncloud-complete-20200731.tar.bz2

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

cd owncloud
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

Now visit https://yourdomain.com or http://YOUR_SERVER_IP to access the Web Installer.

ownCloud Web Installer

Provide admin login details and the database information that we have created previously. Keep database host as “localhost

Finally Finish the Setup

ownCloud Login interface

Now login to ownCloud with username and password.

ownCloud Dashboard

Now you have successfully installed ownCloud in your Debian 9 server.

Let me know the problems you faced while following this tutorial in comment section. I am happy to help you 🙂

Leave a Comment

Your email address will not be published.

You may also like

Hot News