How to Install and Configure OwnCloud on Ubuntu 24.04
The OwnCloud is an open-source utility used to set up your own cloud storage system. It comes with file synchronization and sharing features. Moreover, it allows you to manage your data across all devices such as desktops, and smartphones.
OwnCloud can easily be configured on Ubuntu. This guide will go through comprehensively to install and configure OwnCloud on Ubuntu 24.04 Nobel Numbat.
- Prerequisites
- Step 1. Installing LAMP Stack on Ubuntu
- Step 2: Creating a Database for OwnCloud
- Step 3: Installing OwnCloud on Ubuntu
- Step 4: OwnCloud Configuration Instructions
- Step 5: Accessing OwnCloud
- Configuring OwnCloud using Fully Qualified Domain Name (FQDN)
- Securing OwnCloud
Prerequisites
To set up OwnCloud on the Ubuntu server, you need to fulfill the following requirements.
- Ubuntu 24.04 preferably a fresh installation
- A root user or user with sudo privileges
- LAMP Stack (PHP version 7)
Step 1. Installing LAMP Stack on Ubuntu
OwnCloud requires a complete LAMP stack installation on Ubuntu. The LAMP stack is a robust combination of popular open-source technologies: Linux, Apache, MySQL, and PHP which forms a powerful foundation for web development and hosting.
To install a LAMP stack on Ubuntu we need to install this software.
1. Installing Apache
Apache is a widely used open-source web server. Install it using the APT package manager.
sudo apt install apache2
The Apache web services start automatically; to verify and check the status of the server.
systemctl status apache2.service
The output above verifies that the installation process was successful, and Apache is operational, ready to serve web content, and handle incoming requests effectively.
2. Installing MySQL
MySQL is a sophisticated database management system designed to facilitate the creation, organization, and maintenance of relational databases. To set up MySQL on Ubuntu, utilize the default package manager APT.
sudo apt install mysql-server
You can also install MariaDB which is an open-source fork of MySQL.
sudo apt install mariadb-server
Secure the MySQL installation using the MySQL secure installation interactive script.
sudo mysql_secure_installation
However, in the latest versions of MySQL and MariaDB, it is no longer needed.
verify the MySQL installation using mysql –version command or check service status.
systemctl status mysql.service
3. Installing PHP
OwnCloud highly relies on PHP and its modules. As of writing this guide, the latest OwnCloud does not support PHP, therefore, you need to install PHP7.4.
To install the PHP 7, add the repository.
sudo add-apt-repository ppa:ondrej/php
Install the latest PHP7.4 using the command given below:
sudo apt install php7.4-cli
To verify which version is installed, use the following command.
php --version
Next, install the other required PHP modules for OwnCloud, and execute the following command.
sudo apt install libapache2-mod-php7.4 openssl redis-server wget \ php7.4-ssh2 php7.4-xml php7.4-zip php7.4-apcu \ php7.4 php7.4-imagick php7.4-common php7.4-curl \ php7.4-gd php7.4-imap php7.4-intl php7.4-json \ php7.4-mbstring php7.4-gmp php7.4-bcmath php7.4-mysql \ php7.4-redis php7.4-ldap php-phpseclib -y
Note: Without installing the required modules, the OwnCloud may not work properly.
After installing the packages, reload the Apache web service.
sudo systemctl reload apache2.service
The LAMP stack is successfully installed on Ubuntu. In the upcoming section, we will move forward with the installation process of OwnCloud on your Ubuntu system.
Step 2: Creating a Database for OwnCloud
Creating an OwnCloud database is a crucial step to set it up. This database is used to manage users, files, and permissions.
To create the database, enter the MySQL interactive session using the command given below:
sudo mysql -u root
In the above command, I am entering as root.
Create the database with any name, I am giving it owncloud_db.
CREATE DATABASE owncloud_db;
To view a list of all databases in your MySQL environment, you can use the SHOW DATABASES command.
SHOW DATABASES
Now, create a user with a strong password to manage the database.
CREATE USER 'sam'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
Replace the <password> in the above command with a strong password.
Verify whether the user has been created or not.
SELECT user FROM mysql.user;
Next, grant access to the database to the user.
GRANT ALL PRIVILEGES ON owncloud_db.* TO 'sam'@'localhost';
Now, refresh the user privileges, using the FLUSH PRIVILEGES command.
FLUSH PRIVILEGES;
To exit the MySQL interactive session, type exit and press Enter.
exit
Step 3: Installing OwnCloud on Ubuntu
First of all, download the OwnCloud server archive file.
wget https://download.owncloud.com/server/stable/owncloud-complete-latest.zip
Now, extract the archive file using the unzip utility.
unzip owncloud-complete-latest.zip
Note that the unzip utility comes by default in latest Ubuntu.
After extracting the OwnCloud zip file a folder will be created in the current working directory with the name of owncloud.
Move this folder to the /var/www/html directory which is the default root directory of the webserver to host the web content.
Note: You can move this file to the /srv directory anywhere on your system. But it is up to personal preference.
Now, a crucial step, provide the ownership permission.
sudo chown -R www-data: /var/www/html/owncloud
The above command provides the ownership permissions to the webserver user www-data to process the OwnCloud files.
That’s it OwnCloud has been downloaded and moved to the web server’s root directory. Now, let’s configure it.
Step 4: OwnCloud Configuration Instructions
Apache needs a virtual host file to serve the OwnCloud content. Let’s create a virtual host configuration file in the sites-available directory.
sudo nano /etc/apache2/sites-available/owncloud.conf
The site-enable directory contains the configuration files associated with virtual hosts.
Add the following minimal configurational settings for OwnCloud and save the file.
<VirtualHost *:80> DocumentRoot /var/www/html/owncloud <Directory /var/www/html/owncloud> Options FollowSymlinks AllowOverride All Require all granted </Directory> </VirtualHost>
To test that all the configuration settings are ok, use the apachectl -t command.
apachectl -t
The Syntax OK indicates that there are no issues with the configuration settings. While The warning can be rectified by setting up the server with a fully qualified domain name (FQDN).
Note: The ServerName entry is commented on in the above configuration, if you have a FQDN then you need to enter your domain hostname here.
To ensure that the changes made to the Apache server configuration take effect, it’s important to reload or restart the Apache service
sudo systemctl reload apache2.service
The OwnCloud has been successfully configured.
Step 5: Accessing OwnCloud
Use the following URL in any web browser to access the OwnCloud.
https://localhost/owncloud
An initial setup page will open, where you need to provide the following details.
Username & Password: To configure the username and password for the administrator account type the user’s name and password.
Storage & database: Keep this setting as it is.
Database user & Database password: To proceed with accessing the database, you will need to provide the username and password that were created during Step 2 of the setup process.
Database name: Type the database name which is in our case owncloud_db.
Database host: Keep it localhost.
To finalize the initial configuration process, locate and click on the Finish Setup button.
After finalizing the initial setup, a login page will appear where you can access the OwnCloud.
A web page will open with various folders.
To change the settings of the OwnCloud and manage apps, click on the username and then Settings from the drop-down menu.
The OwnCloud is successfully configured on Ubuntu 24.04.
Configuring OwnCloud using Fully Qualified Domain Name (FQDN)
If you own an active domain, then you can also configure the OwnCloud for FQDN. To achieve this first set the hostname, using the hostnamectl command.
sudo hostnamectl set-hostname mydomain.com
Next, you need to make changes in the Apache configuration file created in Step 4. Open the file in any text editor.
sudo nano /etc/apache2/apache2.conf
Place the lines mentioned below in the file.
<VirtualHost *:80> DocumentRoot /var/www/html/owncloud ServerName mydomain.com <Directory /var/www/html/owncloud> Options FollowSymlinks AllowOverride All Require all granted </Directory> </VirtualHost>
And now, reload the Apache web server.
sudo systemctl reload apache2.service
That’s it, now the OwnCloud will be accessible anywhere.
Note: If you encounter an error, make sure to include ServerName mydomain.com in the owncloud.conf file.
Securing OwnCloud
To secure the OwnCloud installation on Ubuntu follow some best practices.
- Use the HTTPS instead of HTTP
- Enable the SSL/TLS using Let’s Encrypt and Cert Bot utilities (Learn More)
- Use complex passwords
- Implement the intrusion detection
- To protect the SQL injection, validate the user input and use verification techniques
Conclusion
OwnCloud is software that allows you to set up your own cloud storage service. It can easily be installed and set up on the Ubuntu server. You need a complete LAMP stack installation. Following that step, proceed to download the OwnCloud zip file from the designated source and move the downloaded zip file to the root directory of your web server. Lastly, create a virtual host configuration file and configure the OwnCloud to access it.










