ownCloud is an open-source file hosting, file sync, and content collaboration web application that lets users store and share personal content on a private server. ownCloud's cross-platform compatibility allows you to access your files anywhere, and since it runs on your private server, it eliminates any need for third party cloud hosting services.
Similar to cloud hosting services like Dropbox, Google Drive, One Drive among many others, ownCloud allows you to store files and share them with anyone on the Internet.
Prerequisites
- Deploy a Ubuntu 20.04 server instance
- A sudo user account (root access)
- An active domain name pointing to your server
- Install a LAMP stack
Step 1: Create a MySQL database
ownCloud requires a MySQL database. To create a database, login to the MySQL console.
$ mysql -u root -p
Enter the MySQL root password you created earlier when asked. Once logged in, create a new database for ownCloud.
mysql>CREATE DATABASE owncloud;
Create a new database user and assign a password.
CREATE USER 'cloud_user'@'localhost' IDENTIFIED BY 'YOUR_PREFFERED_PASSSWORD';
Now, grant the new user full rights to the ownCloud database.
GRANT ALL PRIVILEGES ON owncloud.* TO 'cloud_user'@'localhost';
Refresh MySQL user privileges and exit.
mysql>FLUSH PRIVILEGES;
mysql>exit
Step 2: Install PHP
You need to install PHP along with all necessary modules required by ownCloud.
$ sudo apt-get install php libapache2-mod-php php-bz2 php-curl php-gd php-imagick php-intl php-common php-imap php-mbstring php-xml php-zip -y
Step 3: Install Owncloud
Method 1: Install and configure Owncloud through a web interface
With webserver software, a database server, and PHP extensions installed on your server, Owncloud can now run without any difficulties. To get started with installation through a web browser, you must download the Owncloud latest version using wget on your Ubuntu server.
$ wget https://download.owncloud.org/community/owncloud-complete-20210721.zip
Move the downloaded file to /var/www/html
.
$ sudo mv owncloud-complete.zip /var/www/html
Confirm the existence of the moved file.
$ ls /var/www/html
Now, uncompress the owncloud-complete Zip file to ready files for installation
$ sudo unzip owncloud-complete.zip
Next, grant Apache read and write access to the new directory
$ sudo chown -R www-data:www-data owncloud/
Edit the default Apache virtual host configuration file, 000-default.conf
and make /var/www/html/owncloud/
your domain’s root directory. Replace cloud.example.com with your actual domain name.
$ sudo nano /etc/apache2/sites-available/000-default.conf
ServerName cloud.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/owncloud
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Save and close the file.
Restart Apache for changes to take effect
$ sudo service apache2 restart
Next, open a web browser on your personal computer (PC) and enter your domain registered on the Ubuntu 21.04 server, or simply enter your server’s public IP address in the URL bar.
http://YOUR_DOMAIN
OR
http://YOUR_SERVER_IP
You will be presented with the Owncloud post-installation screen; enter your preferred administrator username, password. Then, click the Storage and database drop-down to choose MySQL as your database server, enter the database name, user name, and password created on Step 1 of this guide.
Click Finish Setup
to finalize the installation of ownCloud on your server once the provided database information is correct. Next, you will be redirected to the main ownCloud dashboard, where you can get started with configuring your private cloud, upload files, and share links with other users.
To create a new folder and upload new files to your ownCloud server, click the +
symbol on the directory bar and choose between your preferred options. Also, uploaded files can be shared with anyone on the Internet by clicking share and selecting the public link to share your files like you would on file hosting platforms like Google Drive, Dropbox, among others.
Method 2: Manually Install ownCloud via command line
With all required software installed on your server, ownCloud can be manually installed by adding a new repository to apt. But first, a release key has to be downloaded and signed in order for the ownCloud repository to be marked secure.
$ sudo wget -nv https://download.owncloud.org/download/repositories/10.8.0/Ubuntu_21.04/Release.key -O Release.key
Add the downloaded Release package key to your server
$ sudo apt-key add - < Release.key
Now, add the ownCloud repository to your server’s apt sources list.
$ sudo sh -c echo ‘deb https://download.owncloud.org/download/repositories/10.8.0/Ubuntu_21.04/ /’ > /etc/apt/sources.list.d/owncloud.list"
Next, update your server
$ sudo apt-get update
Incase apt update pops errors on the ownCloud repository, simply run
$ sudo apt-get update --allow-unauthenticated
Install ownCloud
$ sudo apt install owncloud -y
OR
$ sudo apt install owncloud-complete-files -y
ownCloud will be automatically installed on your server. By default, the ownCloud directory will be created at /var/www
.
Now, you need to assign the application a default administrator username, password, then set up a database connection to auto-install necessary tables and data using the ownCloud console.
cd /var/www/owncloud/
sudo -u www-data php occ maintenance:install \
--database "mysql" \
--database-name "owncloud" \
--database-user "example_user"\
--database-pass "PASSWORD" \
--admin-user "USERNAME" \
--admin-pass "PASSWORD"
The above commands notify the server to execute php occ arguments as user www-data
to write new files in the ownCloud directory. Once executed, ownCloud will be successfully installed on your server, now, you will need to point your Apache virtual host configuration to the ownCloud directory.
$ sudo nano /etc/apache2/sites-available/000-default.conf
ServerName cloud.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/owncloud/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Save and close the file
Restart Apache
$ sudo systemctl restart apache2
Next, you need to add your domain to the trusted list.
View the current list of trusted domains.
$ cd /var/www/owncloud
$ sudo -u www-data php occ config:system:get trusted_domains
localhost
Add your domain to the list
$ sudo -u www-data php occ config:system:set trusted_domains 1 --value=cloud.example.com
System config value trusted_domains => 1 set to string cloud.example.com
Now, visit your server URL to login and start using ownCloud.
http://YOUR DOMAIN
OR
http://YOUR_SERVER_IP
You have successfully installed ownCloud on Ubuntu 21.04 and can upload, share and download files from your self-hosted cloud server.