ownCloud is a versatile, open-source file-hosting solution that enables you to establish your own personal cloud storage service, similar to Google Drive or Dropbox. This guide provides a comprehensive walkthrough on how to install ownCloud on a Debian 12 server, ensuring you have a secure, self-hosted file-hosting solution on your server.
Prerequisites
Before you embark on the process of installing ownCloud, ensure that you have:
- A Debian 12 server
- A non-root user with admin privileges
- A domain name pointed to your server IP address
Installing Dependencies
ownCloud requires several dependencies to function optimally. These include:
- Apache2 web server
- MariaDB database server
- PHP 7.4
- Redis server
- Additional packages such as ImageMagick, Certbot, Pear, and PHP extensions
The following commands will help you install these dependencies on your system:
sudo apt install lsb-release ca-certificates curl -y sudo curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' sudo apt update sudo apt install apache2 mariadb-server imagemagick certbot python3-certbot-apache smbclient redis-server unzip rsync libapache2-mod-php7.4 php7.4 php7.4-intl php7.4-mysql php7.4-mbstring php7.4-imagick php7.4-igbinary php7.4-gmp php7.4-bcmath php7.4-curl php7.4-gd php7.4-zip php7.4-imap php7.4-ldap php7.4-bz2 php7.4-ssh2 php7.4-common php7.4-json php7.4-xml php7.4-dev php7.4-apcu php7.4-redis libsmbclient-dev php-pear php-phpseclib
After installing the dependencies, verify each one by running the following commands:
sudo systemctl is-enabled apache2 sudo systemctl status apache2 sudo systemctl is-enabled mariadb sudo systemctl status mariadb sudo systemctl is-enabled redis sudo systemctl status redis
Configuring PHP Version
Ensure that you configure the default PHP version on your Debian machine to PHP 7.2, and configure additional PHP tools to use PHP 7.4:
sudo update-alternatives --config php sudo update-alternatives --set phar /usr/bin/phar7.4 sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4 sudo update-alternatives --set phpize /usr/bin/phpize7.4 sudo update-alternatives --set php-config /usr/bin/php-config7.4
Upgrading PHP Pear
After installing the dependencies, it’s time to upgrade PHP Pear to the latest version. Run the following commands:
sudo mkdir -p /tmp/pear/cache sudo pear upgrade --force --alldeps http://pear.php.net/get/PEAR-1.10.13 sudo pear clear-cache sudo pear update-channels sudo pear upgrade --force sudo pear upgrade-all
Configuring MariaDB Server
Next, secure your MariaDB Server installation using the mariadb-secure-installation
utility. You’ll be prompted to answer several questions about the configuration. Afterward, create a new database and user for ownCloud.
sudo mariadb-secure-installation sudo mariadb -u root -p
In the MariaDB Server, execute the following queries:
CREATE DATABASE owncloud; CREATE USER IF NOT EXISTS 'owncloud'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; SHOW GRANTS FOR 'owncloud'@'localhost';
Downloading ownCloud Source Code
After configuring the MariaDB server, download the ownCloud source code and configure the DocumentRoot directory for your ownCloud installation:
cd /var/www wget https://download.owncloud.com/server/stable/owncloud-complete-latest.tar.bz2 wget https://download.owncloud.com/server/stable/owncloud-complete-latest.tar.bz2.sha256 sudo sha256sum -c owncloud-complete-latest.tar.bz2.sha256 < owncloud-complete-latest.tar.bz2 tar -xf owncloud-complete-latest.tar.bz2 sudo chown -R www-data:www-data /var/www/owncloud
Configuring Apache2 Virtual Host
Create a new virtual host configuration for running ownCloud and generate SSL/TLS certificates from Letsencrypt using Certbot:
sudo a2enmod rewrite env dir mime unique_id headers ssl sudo nano /etc/apache2/sites-available/owncloud.conf sudo a2ensite owncloud.conf sudo apachectl configtest sudo systemctl restart apache2 sudo certbot --apache --agree-tos --no-eff-email --redirect --hsts --staple-ocsp --email [email protected] -d example.io
Installing ownCloud via Command Line
Now that all dependencies are installed and configured, you can start the installation step via a web browser or command line. In this guide, we’ll install ownCloud via the command line:
cd /var/www/owncloud sudo -u www-data /var/www/owncloud/occ maintenance:install \ --database "mysql" \ --database-name "owncloud" \ --database-user "owncloud"\ --database-pass "password" \ --admin-user "admin" \ --admin-pass "adminpassowncloud"
Configuring ownCloud
After installing ownCloud, configure it by adding your domain name to the trusted_domains
in the config.php
file.
sudo nano /var/www/owncloud/config/config.php
Logging into ownCloud
After installation, open your web browser and visit your ownCloud domain name. You’ll be redirected to a secure HTTPS connection and will see the ownCloud login page. Enter your admin user and password, then click Login.
Performance Tuning for ownCloud
After the installation, enhance your ownCloud setup by creating a new cron for ownCloud and integrating Redis into your ownCloud installation:
sudo crontab -u www-data -e sudo nano /var/www/owncloud/config/config.php
Conclusion
Congratulations! You’ve successfully installed ownCloud on your Debian 12 server. You’ve installed ownCloud with the LAMP Stack (Apache2, MariaDB, and PHP), secured ownCloud with SSL/TLS certificates from Letsencrypt, and integrated a Redis server into your ownCloud installation.
For enhanced performance and uncompromised security, consider utilizing Shape.host services. With their SSD Linux VPS, you can enjoy high-performance service, ensuring that your ownCloud installation runs seamlessly.