Last updated
Self-Hosted
Set up ownCloud on Ubuntu with NGINX and MariaDB for self-hosted file storage and sharing.
Contents
Prerequisites
- Ubuntu 20.04+ server
- NGINX installed and running
- MariaDB or MySQL installed
- Domain name pointing to your server
Install PHP
sudo apt update
sudo apt install -y php8.1 php8.1-fpm php8.1-gd php8.1-json php8.1-mysql php8.1-curl php8.1-mbstring php8.1-intl php8.1-imagick php8.1-xml php8.1-zip php8.1-bcmath php8.1-gmp
Create the Database
sudo mysql -u root -p
CREATE DATABASE owncloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'owncloud'@'localhost' IDENTIFIED BY 'StrongPassword!';
GRANT ALL ON owncloud.* TO 'owncloud'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Download ownCloud
cd /var/www
sudo wget https://download.owncloud.com/server/stable/owncloud-complete-latest.tar.bz2
sudo tar -xjf owncloud-complete-latest.tar.bz2
sudo chown -R www-data:www-data owncloud/
NGINX Configuration
sudo nano /etc/nginx/sites-available/owncloud
server {
listen 80;
server_name files.yourdomain.com;
root /var/www/owncloud;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
}
sudo ln -s /etc/nginx/sites-available/owncloud /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
Add SSL with Let’s Encrypt
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d files.yourdomain.com
Finish Installation
Browse to https://files.yourdomain.com and complete the web installer by entering your database credentials and admin user details.