Free Trial

Free VPS Trial, no credit card required

Start Free Trial
How To Install OwnCloud on Ubuntu Server 20.04 LTS

How To Install OwnCloud on Ubuntu Server 20.04 LTS

Christos Azami

Christos Azami · Systems Administrator

Nov 03, 2021 · Tutorials

This is a step-by-step guide on how to install ownCloud Collaboration software on a fresh installation of Ubuntu 20.04 server. Run the following commands in your terminal to complete the installation.

Prerequisites

  • A fresh installation of Ubuntu 20.04 with SSH enabled.
  • This guide assumes that you are working as the root user.
  • Your ownCloud directory will be located in /var/www/owncloud/

Preparation

First, ensure that all the installed packages are entirely up to date, and that PHP is available in the APT repository. To do so, follow the instructions below:

apt update && \
  apt upgrade -y

Create the occ Helper Script

Create a helper script to simplify running occ commands.

Select all the commands below and just copy-paste to the terminal. 

FILE="/usr/local/bin/occ"
/bin/cat <<EOM >$FILE
#! /bin/bash
cd /var/www/owncloud
sudo -E -u www-data /usr/bin/php /var/www/owncloud/occ "\$@"
EOM

Make the helper script executable:

chmod +x /usr/local/bin/occ

Install the Required Packages

Select all the commands below and just copy-paste to the terminal.

apt install -y \
  apache2 \
  libapache2-mod-php \
  mariadb-server \
  openssl \
  php-imagick php-common php-curl \
  php-gd php-imap php-intl \
  php-json php-mbstring php-mysql \
  php-ssh2 php-xml php-zip \
  php-apcu php-redis redis-server \
  wget

Note : php 7.4 is the default version installable with Ubuntu 20.04

Install the Recommended Packages

Select all the commands below and just copy-paste to the terminal.

apt install -y \
  ssh bzip2 rsync curl jq \
  inetutils-ping coreutils

We are ready, now, to proceed with OwnCloud Installation.

Installation Steps

1. Configure Apache

1.1. Change the Document Root

sed -i "s#html#owncloud#" /etc/apache2/sites-available/000-default.conf
service apache2 restart

1.2. Create a Virtual Host Configuration

Select all the commands below and just copy-paste to the terminal.

FILE="/etc/apache2/sites-available/owncloud.conf"
/bin/cat <<EOM >$FILE
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>
EOM

2. Enable the Virtual Host Configuration

a2ensite owncloud.conf
service apache2 reload

3. Configure the Database

mysql -u root -e "CREATE DATABASE IF NOT EXISTS owncloud; \
GRANT ALL PRIVILEGES ON owncloud.* \
  TO owncloud@localhost \
  IDENTIFIED BY 'password'";

3.1. Enable the Recommended Apache Modules

echo "Enabling Apache Modules"
a2enmod dir env headers mime rewrite setenvif
service apache2 reload

4. Download ownCloud

cd /var/www/
wget https://download.owncloud.org/community/owncloud-10.8.0.tar.bz2 && \
tar -xjf owncloud-10.8.0.tar.bz2 && \
chown -R www-data. owncloud

5. Install ownCloud

Select all the commands below and just copy-paste to the terminal.

occ maintenance:install \
    --database "mysql" \
    --database-name "owncloud" \
    --database-user "owncloud" \
    --database-pass "password" \
    --admin-user "admin" \
    --admin-pass "admin"

6. Configure ownCloud’s Trusted Domains

myip=$(hostname -I|cut -f1 -d ' ')
occ config:system:set trusted_domains 1 --value="$myip"

7. Set Up a Cron Job

Set your background job mode to cron:

occ background:cron
echo "*/15  *  *  *  * /var/www/owncloud/occ system:cron" \
  > /var/spool/cron/crontabs/www-data
chown www-data.crontab /var/spool/cron/crontabs/www-data
chmod 0600 /var/spool/cron/crontabs/www-data

If you need to sync your users from an LDAP or Active Directory Server, add this additional Cron job. Every 15 minutes this cron job will sync LDAP users in ownCloud and disable the ones who are not available for ownCloud. Additionally, you get a log file in /var/log/ldap-sync/user-sync.log for debugging.

Select all the commands below and just copy-paste to the terminal.

echo "*/15 * * * * /var/www/owncloud/occ user:sync 'OCA\User_LDAP\User_Proxy' -m disable -vvv >> /var/log/ldap-sync/user-sync.log 2>&1" >> /var/spool/cron/crontabs/www-data
chown www-data.crontab  /var/spool/cron/crontabs/www-data
chmod 0600  /var/spool/cron/crontabs/www-data
mkdir -p /var/log/ldap-sync
touch /var/log/ldap-sync/user-sync.log
chown www-data. /var/log/ldap-sync/user-sync.log

8. Configure Caching and File Locking

Execute these commands:

Select all the commands below and just copy-paste to the terminal.

occ config:system:set \
   memcache.local \
   --value '\OC\Memcache\APCu'
occ config:system:set \
   memcache.locking \
   --value '\OC\Memcache\Redis'
occ config:system:set \
   redis \
   --value '{"host": "127.0.0.1", "port": "6379"}' \
   --type json

9. Configure Log Rotation

Execute this command to set up log rotation.

Select all the commands below and just copy-paste to the terminal.

FILE="/etc/logrotate.d/owncloud"
sudo /bin/cat <<EOM >$FILE
/var/www/owncloud/data/owncloud.log {
  size 10M
  rotate 12
  copytruncate
  missingok
  compress
  compresscmd /bin/gzip
}
EOM

10. Finalize the Installation

Make sure the permissions are correct.

cd /var/www/
chown -R www-data. owncloud

Get OwnCloud as Virtual or Dedicated Server

NetShop ISP offers OwnCloud as a Virtual Private Server (VPS) or you can install it on a Bare-metal Dedicated Server.

Minimum VPS Plan: 1 vCPU, 512GB RAM, 20GB SSD. Locations: Cyprus, Malta, United Kingdom, Netherlands, Singapore

Minimum Specs Dedicated Server: Check our Offers to find the server with the best pricing that matches your budget.

Related Articles

Categories

Backup
6
Business Continuity
4
Cloud Hosting
9
Colocation
4
Company Updates
1
Cryptocurrencies
1
Data Centers
12
Dedicated Servers
4
Disaster Recovery
2
Forex
18
Gaming
1
iGaming
30
Industry News
31
Interviews
7
Joomla
9
Magento
5
Managed Services
1
Press Releases
49
Product News
6
Resellers
1
Security
22
Software & Apps
1
Streaming
1
Tech Startups
12
Tutorials
37
Uncategorized
390
Vps Hosting
10
Web Design & Development
3
Web Hosting
42
Webinars
1
Wordpress
14

Free VPS Trial

No Credit Card Required.

Recent Posts

Best 5 Open Source Web Servers in 2022

Best 5 Open Source Web Servers in 2022

05 July, 2022

NetShop ISP Completes Casino Games Audit for Slots Development Company, Fugaso

NetShop ISP Completes Casino Games Audit for Slots Development Company, Fugaso

30 June, 2022

How To Install Zimbra 9 on Ubuntu 20.04 Server using Automatic Installer

How To Install Zimbra 9 on Ubuntu 20.04 Server using Automatic Installer

29 June, 2022

NetShop ISP Announces Reinforcement of myNetShop Security with Multi-Factor Authentication

NetShop ISP Announces Reinforcement of myNetShop Security with Multi-Factor Authentication

28 June, 2022

Magento 2 Hosting: Recommended Hardware Requirements

Magento 2 Hosting: Recommended Hardware Requirements

24 June, 2022

Products

Bare Metal Dedicated Servers

Virtual Servers (VPS / VDS)

Rack Space & Colocation Hosting

Fast Web Hosting

Cloud Backup

Premium DNS Hosting

Resources

Blog

Videos

Events

APIConnect

WhitepapersNew

Company

About Us

CareersNew

Awards & Honours

Become a Partner

Contact Us

#letushostyou

Award Winning Hosting Provider with a Customer-centric approach to Business and an Open Source Mindset regarding Solutions and Products Development.

Est. 2004, Larnaca – Cyprus


About

Legal Address: 2A, Marathonos, Livadhia, 7060, Cyprus

Operations Office: 120, Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca, 6031, Cyprus

Company Reg: HE 217340
EU VAT Number: CY10217340J
ISO 9001:2015: No. QS.21.038

International Phone: +357 2425 0808