Table of Contents#
- Prerequisites
- Step 1: Update System Packages
- Step 2: Install the LAMP Stack
- Step 3: Configure MariaDB for OwnCloud
- Step 4: Download and Install OwnCloud
- Step 5: Configure Apache for OwnCloud
- Step 6: Complete Installation via Web Wizard
- Step 7: Post-Installation Configuration
- Troubleshooting Common Issues
- Conclusion
- References
Prerequisites#
Before you start, ensure you have:
- A server running Rocky Linux 8/9 or AlmaLinux 8/9 (we’ll use Rocky Linux 9 in examples).
- At least 2 GB of RAM (4 GB recommended for better performance).
- 20 GB of disk space (more if you plan to store large files).
- Root or
sudoprivileges. - A registered domain name (optional but recommended for HTTPS).
- A stable internet connection.
Step 1: Update System Packages#
Always start by updating your system to ensure you have the latest security patches and dependencies:
sudo dnf update -yThis command will:
- Refresh your package repositories.
- Upgrade all installed packages to their latest versions.
Step 2: Install the LAMP Stack#
OwnCloud requires a LAMP stack (Linux, Apache, MariaDB, PHP) to run. We’ll install each component one by one.
2.1 Install Apache Web Server#
Apache is the most widely used web server for hosting PHP applications like OwnCloud.
-
Install Apache:
sudo dnf install httpd -y -
Enable and start the Apache service:
sudo systemctl enable --now httpd -
Allow HTTP (port 80) and HTTPS (port 443) through the firewall:
sudo firewall-cmd --add-service=http --permanent sudo firewall-cmd --add-service=https --permanent sudo firewall-cmd --reload
Verify Apache is running by visiting your server’s IP address in a browser (e.g., http://your-server-ip). You should see the default Apache test page.
2.2 Install MariaDB Database Server#
MariaDB is a drop-in replacement for MySQL and is required to store OwnCloud’s data (users, files, settings).
-
Install MariaDB:
sudo dnf install mariadb-server -y -
Enable and start MariaDB:
sudo systemctl enable --now mariadb -
Secure MariaDB (critical for production):
Run themysql_secure_installationscript to:- Set a root password.
- Remove anonymous users.
- Disallow remote root login.
- Remove the test database.
sudo mysql_secure_installationFollow the prompts:
- Enter current password for root (leave blank if new: press Enter).
- Set a strong root password (e.g.,
MyS3cr3tP@ssw0rd). - Answer
Yto all remaining questions.
2.3 Install PHP and Required Extensions#
OwnCloud requires PHP 8.1 or higher (as of 2024). Rocky Linux 9/AlmaLinux 9’s default AppStream repository includes PHP 8.0, so we’ll use the Remi repository to install PHP 8.1.
-
Install the Remi repository:
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y -
Reset the PHP module and enable PHP 8.1:
sudo dnf module reset php -y sudo dnf module enable php:remi-8.1 -y -
Install PHP and required extensions:
OwnCloud needs specific PHP extensions to handle files, databases, and media. Install them with:sudo dnf install php php-gd php-json php-mbstring php-curl php-intl php-mysqlnd php-imagick php-xml php-zip php-opcache php-redis -yHere’s what each extension does:
php-gd: Image manipulation.php-mysqlnd: MySQL/MariaDB support.php-imagick: Advanced image processing.php-redis: Redis caching (optional but recommended).
-
Adjust PHP settings for OwnCloud:
Edit thephp.inifile (location:/etc/php.ini) to optimize performance:sudo nano /etc/php.iniChange the following values (use
Ctrl+Wto search):memory_limit = 512M(increase from 128M for larger files).upload_max_filesize = 10G(allow large file uploads).post_max_size = 10G(matchupload_max_filesize).max_execution_time = 300(increase from 30 for long-running tasks).
Save and exit (
Ctrl+O,Enter,Ctrl+X). -
Restart Apache to apply PHP changes:
sudo systemctl restart httpd
Step 3: Configure MariaDB for OwnCloud#
Next, create a dedicated database and user for OwnCloud (never use the root user for applications).
-
Log in to MariaDB as root:
mysql -u root -pEnter the root password you set earlier.
-
Create a database (e.g.,
owncloud_db):CREATE DATABASE owncloud_db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;utf8mb4ensures support for emojis and non-Latin characters.
-
Create a database user (e.g.,
owncloud_user) with a strong password:CREATE USER 'owncloud_user'@'localhost' IDENTIFIED BY 'YourStrongPassword123!'; -
Grant full privileges on the database to the user:
GRANT ALL PRIVILEGES ON owncloud_db.* TO 'owncloud_user'@'localhost'; -
Flush privileges and exit:
FLUSH PRIVILEGES; EXIT;
Step 4: Download and Install OwnCloud#
-
Navigate to the web root directory (
/var/www/html):cd /var/www/html -
Download the latest stable OwnCloud release:
sudo wget https://download.owncloud.com/server/stable/owncloud-latest.tar.bz2 -
Verify the download (optional but secure):
OwnCloud provides SHA256 checksums to ensure the file isn’t corrupted. Download the checksum file and verify:sudo wget https://download.owncloud.com/server/stable/owncloud-latest.tar.bz2.sha256 sudo sha256sum -c owncloud-latest.tar.bz2.sha256You should see:
owncloud-latest.tar.bz2: OK -
Extract the tarball:
sudo tar -xjf owncloud-latest.tar.bz2 -
Set proper file permissions:
OwnCloud requires the Apache user (apache) to read/write to critical directories (e.g.,data,config).sudo chown -R apache:apache /var/www/html/owncloud sudo chmod -R 750 /var/www/html/owncloud sudo chmod -R 770 /var/www/html/owncloud/data750: Directories are readable/writable by the owner (apache) and group (apache), but not by others.770: Thedatadirectory needs write access for file uploads.
Step 5: Configure Apache for OwnCloud#
Apache needs a virtual host to serve OwnCloud. A virtual host tells Apache how to handle requests for your domain (or IP).
-
Create a virtual host file:
sudo nano /etc/httpd/conf.d/owncloud.conf -
Paste the following configuration (replace
your-domain.comwith your actual domain or IP):<VirtualHost *:80> ServerName your-domain.com ServerAlias www.your-domain.com DocumentRoot /var/www/html/owncloud ErrorLog /var/log/httpd/owncloud_error.log CustomLog /var/log/httpd/owncloud_access.log combined <Directory /var/www/html/owncloud> AllowOverride All Require all granted Options FollowSymLinks MultiViews <IfModule mod_dav.c> Dav off </IfModule> </Directory> </VirtualHost>Key settings:
ServerName: Your domain name (e.g.,cloud.your-domain.com).DocumentRoot: Path to the OwnCloud installation.AllowOverride All: Enables.htaccessfiles (required for OwnCloud’s URL rewriting).
-
Test the Apache configuration:
sudo apachectl configtestYou should see
Syntax OK. If not, fix any syntax errors in the virtual host file. -
Restart Apache to apply changes:
sudo systemctl restart httpd
Step 6: Complete Installation via Web Wizard#
Now access the OwnCloud web interface to finalize the setup.
-
Open a browser and go to:
- If using a domain:
http://your-domain.com - If using an IP:
http://your-server-ip
- If using a domain:
-
Fill out the form:
- Create an admin account: Enter a username (e.g.,
admin) and strong password. - Configure the database:
- Select
MySQL/MariaDB. - Database user:
owncloud_user - Database password: The password you set for
owncloud_user. - Database name:
owncloud_db - Host:
localhost
- Select
Example:

- Create an admin account: Enter a username (e.g.,
-
Click Finish setup.
OwnCloud will now create tables in the database and set up the admin account. Once done, you’ll be redirected to the dashboard!
Step 7: Post-Installation Configuration#
These steps are critical for security, performance, and reliability.
7.1 Secure with HTTPS (Let’s Encrypt)#
HTTPS encrypts data between your browser and the server—never skip this for production. We’ll use Let’s Encrypt (free SSL certificates).
-
Install the EPEL repository (required for Certbot):
sudo dnf install epel-release -y -
Install Certbot and the Apache plugin:
sudo dnf install certbot python3-certbot-apache -y -
Run Certbot to obtain a certificate:
sudo certbot --apacheFollow the prompts:
- Enter your email (for renewal notifications).
- Agree to the Let’s Encrypt terms of service.
- Choose whether to share your email (optional).
- Select your domain (e.g.,
your-domain.com).
Certbot will:
- Automatically install the SSL certificate.
- Update your Apache virtual host to redirect HTTP to HTTPS.
- Schedule automatic certificate renewals (Let’s Encrypt certificates expire every 90 days).
Verify HTTPS works by visiting https://your-domain.com—you should see a padlock in the browser bar.
7.2 Set Up Cron Jobs for Background Tasks#
OwnCloud uses background jobs to handle tasks like:
- File synchronization.
- Email notifications.
- Log rotation.
The default method (AJAX) is unreliable for production. Instead, use system cron (more efficient).
-
Create a cron job for the Apache user:
sudo crontab -u apache -e -
Add the following line (runs the cron job every 15 minutes):
*/15 * * * * php -f /var/www/html/owncloud/cron.php -
Save and exit (
Ctrl+O,Enter,Ctrl+X). -
Enable cron in OwnCloud:
- Log in to OwnCloud as admin.
- Go to Settings > Basic Settings.
- Under Background Jobs, select Cron.
- Click Save.
7.3 Enable Redis Caching (Optional but Recommended)#
Redis is an in-memory data store that speeds up OwnCloud by caching frequent requests (e.g., user sessions, file metadata).
-
Install Redis:
sudo dnf install redis -y -
Enable and start Redis:
sudo systemctl enable --now redis -
Configure OwnCloud to use Redis:
Edit the OwnCloud config file (/var/www/html/owncloud/config/config.php):sudo nano /var/www/html/owncloud/config/config.phpAdd these lines (replace with your Redis settings if using a remote server):
'memcache.local' => '\OC\Memcache\Redis', 'memcache.distributed' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => [ 'host' => 'localhost', 'port' => 6379, ], -
Restart Apache:
sudo systemctl restart httpd
7.4 Adjust SELinux Policies (If Enabled)#
SELinux (Security-Enhanced Linux) is enabled by default on Rocky/AlmaLinux. It can block Apache from accessing OwnCloud’s files if not configured correctly.
-
Check if SELinux is enabled:
sestatusIf you see
SELinux status: enabled, proceed. -
Allow Apache to read/write OwnCloud directories:
sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/owncloud/data(/.*)?' sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/owncloud/config(/.*)?' sudo semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/owncloud/apps(/.*)?' sudo restorecon -Rv /var/www/html/owncloud/ -
Allow Apache to connect to MariaDB:
sudo setsebool -P httpd_can_network_connect_db 1 -
Allow Apache to use unified processes:
sudo setsebool -P httpd_unified 1
Step 8: Test OwnCloud#
Log in to your OwnCloud dashboard (https://your-domain.com) and test basic functionality:
- Upload a file (e.g., a photo or document).
- Create a new user (Settings > Users).
- Share a file with another user (right-click the file > Share).
If everything works, congratulations—you have a fully functional OwnCloud server!
Troubleshooting Common Issues#
Here are fixes for the most frequent problems:
1. “Permission Denied” Errors#
- Cause: Incorrect file ownership/permissions.
- Fix: Reapply permissions:
sudo chown -R apache:apache /var/www/html/owncloud sudo chmod -R 750 /var/www/html/owncloud
2. PHP Extension Missing#
- Cause: A required PHP extension isn’t installed.
- Fix: Install the missing extension (e.g.,
php-imagick):sudo dnf install php-imagick -y sudo systemctl restart httpd
3. Database Connection Error#
- Cause: Incorrect database credentials in the web installer.
- Fix: Recheck the database name, user, and password in Step 3.
4. SELinux Blocking Access#
-
Cause: SELinux policies are too strict.
-
Fix: Temporarily disable SELinux to test (only for debugging):
sudo setenforce 0If the issue resolves, re-enable SELinux and adjust policies (Step 7.4).
5. Apache Error Logs#
Always check Apache’s error log for clues:
sudo tail -f /var/log/httpd/owncloud_error.logConclusion#
You’ve successfully installed OwnCloud on Rocky Linux or AlmaLinux! You now have a private, self-hosted cloud storage solution with:
- Secure HTTPS encryption.
- Automatic background tasks (cron).
- Redis caching for speed.
- Regular security updates.
Next steps:
- Explore OwnCloud apps (e.g., calendar, contacts, office integration).
- Back up your OwnCloud data (Settings > Backup).
- Configure two-factor authentication (Settings > Security) for extra security.
References#
- OwnCloud Official Documentation
- Rocky Linux Documentation
- AlmaLinux Documentation
- Let’s Encrypt Certbot Guide
- Remi Repository PHP Installation
Let me know if you have any questions—happy hosting! 🚀