How to install ownCloud on Debian 9

 In Dedicated, VPS, Web

Requirements:

    • root access via SSH to your VPS;
    • MySQL or MariaDB 5.5+ or PostgreSQL;
    • PHP version 5.6 or above;
    • Apache 2.4 with prefork Multi-Processing Module (MPM) and mod_php;

1. Connect to your server

To connect to your server via SSH as user root, use the following command:

ssh root@IP_ADDRESS -p PORT_NUMBER

and replace “IP_ADDRESS” and “PORT_NUMBER” with your actual server IP address and SSH port number.

Once logged in, make sure that your server is up-to-date by running the following commands:

apt-get update
apt-get upgrade

2. Install Apache web server

Check whether Apache is already installed and running on your server. The following command will help you in that matter:

dpkg -l apache2

In case you already have an Apache web server on your system then you can skip these steps.

apt install apache2

Once installed, start the Apache server and enable it to start at server boot.

systemctl start apache2
systemctl enable apache2

3. Install PHP

Install PHP together with some PHP modules that are required by ownCloud with the following command:

sudo apt install php7.0 php7.0-common libapache2-mod-php7.0 \
    openssl php-imagick php7.0-curl php7.0-gd php7.0-mcrypt \
    php7.0-imap php7.0-intl php7.0-json php7.0-ldap php7.0-mbstring \
    php7.0-mysql php7.0-pgsql php-smbclient php-ssh2 \
    php7.0-sqlite3 php7.0-xml php7.0-zip php-redis php-apcu

4. Install MariaDB and create a database

In this tutorial, we will use MariaDB as a database engine. We can Install MariaDB server from Debian base repository using the following command:

sudo apt update
sudo apt -y install mariadb-server

When the installation is complete, run the following commands to start and enable the MariaDB service :

sudo systemctl start mariadb
sudo systemctl enable mariadb

To secure your installation and to set up the root password execute the following command on your server.

sudo mysql_secure_installation

If you did not set any password during the installation, you can just leave it blank and press Enter.

Next step is to log in to the MariaDB server as ‘root’ user and creates a database and user for ownCloud.

mysql -u root -p
MariaDB [(none)]> CREATE DATABASE owncloud CHARACTER SET utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud'@'localhost' IDENTIFIED BY 'Password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

It is recommended to replace ‘Password’ with a strong password which will be a combination of letters and numbers and at least 10 characters long.

5. Install ownCloud

The ownCLoud 10 package is not available in default Debian 9 repositories so we will install the package from the official ownCloud repositories. First, add the ownCloud GPG key to the apt sources keyring:

wget -qO- https://download.owncloud.org/download/repositories/stable/Debian_9.0/Release.key | sudo apt-key add -

once the key is added run the following command to enable the ownCloud repository:

echo 'deb https://download.owncloud.org/download/repositories/stable/Debian_9.0/ /' | sudo tee /etc/apt/sources.list.d/owncloud.list

Before installing the ownCloud package we need to enable HTTPS transport for the Debian apt tool by installing the following package:

sudo apt install apt-transport-https

Update the apt cache list and install the ownCloud package with the following command:

sudo apt update 
sudo apt install owncloud-files

The command above will install the ownCloud files in the /var/www/owncloud directory.

6. Create Apache Virtual Host

To access the ownCloud with a domain name you need to create a virtual host. Open a new configuration file using nano or your favorite text editor with the following command:

nano /etc/apache2/sites-available/your_domain.com.conf

Don’t forget to modify the your_domain.com and add the following lines:

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>
ErrorLog /var/log/apache2/owncloud-error_log
CustomLog /var/log/apache2/owncloud-access_log common

Save the file.

Enable the Apache ownCloud configuration:

sudo a2ensite your_domain.com.conf

Remember to replace your ‘your_domain.com’ with your actual domain name. Save the changes and restart the Apache web server for the changes to take effect:

systemctl reload apache2

6. Finish the ownCloud installation

In the last step of this guide, we need to access to ownCloud Web Interface and finish the installation.

To finish the installation open your browser and navigate to

http://your_server_ip_address/owncloud/

After completing setup you will get admin dashboard.

That’s it. If you followed all of the instructions properly now you should be able to access your ownCloud with your domain name on your Debian 9 server.

Recommended Posts

Start typing and press Enter to search