Skip to content
Follow
CMS

How to Install ownCloud with Nginx on Ubuntu 24.04

Richard
Written by
Richard
Jun 4, 2024 Updated Sep 15, 2026 7 min read
ownCloud featured image
ownCloud featured image

ownCloud with Nginx on Ubuntu 24.04 gives you a private cloud storage server to sync and share files securely while keeping full control of your data. This setup uses ownCloud version 10.13.1 running on top of the Nginx web server to handle traffic quickly and efficiently.

Advertisement

Getting this self-hosted storage working on your system takes a few steps to install the web server, database, and PHP packages so you can log in through your web browser.

⚡ Quick Answer

Install Nginx and MariaDB using `sudo apt install nginx mariadb-server`. Create an ownCloud database and user within MariaDB. Finally, install PHP-FPM and the ownCloud application files.

Advertisement

Install Nginx HTTP server on Ubuntu

To install Nginx HTTP server on Ubuntu, open your terminal and run the commands sudo apt update and sudo apt install nginx. This free web server handles incoming web traffic and serves your ownCloud files to visitors over the internet.

To do that, open the Ubuntu terminal and run the commands below to install the Nginx web server.

sudo apt update
sudo apt install nginx

Once Nginx is installed, the commands below can start, stop, and enable the Nginx web server to start automatically when your server boots up.

sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl enable nginx

You can test the Nginx web server by opening your web browser and browsing to the server’s localhost or IP address.

Advertisement

http://localhost

Default Nginx welcome page displayed after installation on Ubuntu 24.04
Default Nginx welcome page displayed after installation on Ubuntu 24.04

When you see "Welcome to nginx!" the Nginx HTTP server has been installed.

Additional help on installing Nginx on Ubuntu is in the link below.

How to install Nginx on Ubuntu

Advertisement

Install MariaDB database server on Ubuntu Linux

To install MariaDB database server on Ubuntu Linux, open your terminal and run the commands sudo apt update and sudo apt install mariadb-server. This database system stores all user accounts, file details, and settings for your ownCloud installation.

To install and use the MariaDB database server, use the instructions below.

Open the Ubuntu terminal and run the commands below to install the MariaDB database server.

sudo apt update
sudo apt install mariadb-server

Once the MariaDB database server is installed, use the commands below to stop, start, and enable the MariaDB server to start automatically when the server boots.

Advertisement
sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the following commands to validate and test if the MariaDB database server is installed successfully.

sudo mariadb

Once you run the commands above, it will log you onto the MariaDB console and display a message similar to the one below.

Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 32
Server version: 10.11.2-MariaDB-1 Ubuntu 23.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> 

The message tells you that the server is installed successfully.

Additional help on installing MariaDB.

Advertisement

Create an ownCloud database

To create an ownCloud database, log into your MariaDB prompt and run the SQL commands to create a dedicated database named ownclouddb and a user account called ownclouddbuser with full permissions. This gives your cloud storage a secure, isolated space to store information.

As part of the setup, we will create a database named 'ownclouddb' and a corresponding user account called 'ownclouddbuser.'

Finally, we'll grant the ownclouddbuser full access to the ownclouddb database.

All the database steps above can be done using the commands below:

Advertisement

But first, log on to the MariaDB database server:

sudo mariadb

Then run the commands below to complete the steps:

CREATE DATABASE ownclouddb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER ownclouddbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON ownclouddb.* TO ownclouddbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
⚠️WarningEnsure to replace 'type_your_password_here 'with your password.

Ensure to replace 'type_your_password_here 'with your password.

Install PHP-FPM on Ubuntu Linux

To install PHP-FPM on Ubuntu Linux, run the package installation commands in your terminal to set up the PHP version required by your cloud software. PHP-FPM (FastCGI Process Manager) processes the backend code that makes your ownCloud interface run smoothly.

Advertisement

ownCloud runs with PHP version 7.4. PHP 8.x is not currently supported. Always check the official PHP requirements page to ensure you are installing the latest compatible version for ownCloud.

Run the commands below to install PHP 7.4-FPM.

First, add the following repository.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Then, install PHP 7.4 using the command below.

sudo apt install php7.4-fpm php7.4-intl php7.4-mysql php7.4-curl php7.4-cli php7.4-zip php7.4-xml php7.4-gd php7.4-gmp php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-json php7.4-sqlite3 php7.4-ldap php7.4-imap php7.4-pgsql php7.4-ssh2 php7.4-soap php7.4-zip

Additional help on installing PHP

How to install PHP on Ubuntu Linux

Download ownCloud files

To download ownCloud files, visit the official download page to get the latest archive release and extract it to your web server directory. Getting the official source files is the necessary first step before you configure permissions and run the web installer.

💡TipAlways check the download page for the latest release.

Replace the download link below with the current so you have the latest version.

First, navigate to the /tmp/ directory and download ownCloud files. After unzipping the file, move the content into the ownCloud folder in the Nginx root directory.

The final step is to change the permissions. This will allow the Nginx web server to safely interact with the files, ensuring a secure environment for your ownCloud installation.

wget https://download.owncloud.com/server/stable/owncloud-complete-20240226.zip -P /tmp
sudo unzip /tmp/owncloud-complete-20240226.zip -d /var/www
sudo chown -R www-data:www-data /var/www/owncloud/

Once all the steps are done, configure the Nginx webserver to serve the ownCloud content.

Run the commands below to create a Nginx server block file for your ownCloud.

sudo nano /etc/nginx/sites-available/owncloud.conf

Then, copy and paste the content block below into the Nginx server block.

upstream php-handler {
server unix:/var/run/php/php7.4-fpm.sock;
}

server {
listen 80;
listen [::]:80;
server_name owncloud.example.com;
root /var/www/owncloud;

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

# set max upload size
client_max_body_size 512M;
fastcgi_buffers 64 4K;

# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

location / {
rewrite ^ /index.php;
}

location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}
location ~ ^/(?:.|autotest|occ|issue|indie|db_|console) {
deny all;
}

location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|oc[ms]-provider/.+|.+/richdocumentscode/proxy).php(?:$|/) {
fastcgi_split_path_info ^(.+?.php)(/.*|)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param modHeadersAvailable true;
# Enable pretty urls
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}

location ~ ^/(?:updater|oc[ms]-provider)(?:$|/) {
try_files $uri/ =404;
index index.php;
}

# Adding the cache control header for js, css and map files
# Make sure it is BELOW the PHP block
location ~ .(?:css|js|woff2?|svg|gif|map)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463";
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Download-Options "noopen" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "none" always;
add_header X-XSS-Protection "1; mode=block" always;

# Optional: Don't log access to assets
access_log off;
}

location ~ .(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
try_files $uri /index.php$request_uri;
# Optional: Don't log access to other assets
access_log off;
}
}

Save the file.

To enable the server block for your ownCloud installation and restart the Nginx web server, run the command `sudo ln -s /etc/nginx/sites-available/owncloud.conf /etc/nginx/sites-enabled/` followed by `sudo systemctl restart nginx`. This action makes the Nginx server use the specific configuration file you created for ownCloud, allowing it to serve your cloud files.

sudo ln -s /etc/nginx/sites-available/owncloud.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx.service

Setup Let's Encrypt SSL/TLS for ownCloud

To setup Let's Encrypt SSL/TLS for ownCloud, install the Certbot tool and request a free security certificate for your domain name. This encryption turns your standard HTTP connection into a secure HTTPS connection to protect your passwords and private files.

Please read the post below for additional resources on installing and creating Let's Encrypt SSL certificates for Nginx.

How to set up Let's Encrypt SSL certificate for Nginx on Ubuntu Linux

Once you have restarted the Nginx web server, open your browser and browse to the server hostname or IP address defined in the Nginx server block.

http://owncloud.example.com

An ownCloud installation wizard page should appear. Create an administrator account and password, enter the database name, database account name, and password created above, and click Finish setup.

owncloud installation wizard finish
owncloud installation wizard finish

Your ownCloud site should be ready to use.

owncloud dashboard
owncloud dashboard

That should do it!

Conclusion:

  • Setting up OwnCloud with Nginx support on Ubuntu provides a reliable and efficient file hosting service.
  • Nginx, known for its high performance and low memory usage, ensures fast and stable performance for file sharing and synchronization needs.
  • I am installing MariaDB as the database server, which ensures seamless data management and supports the OwnCloud application.
  • Including PHP-FPM completes the environment necessary to run OwnCloud, offering robust support for PHP-based applications.
  • After following the installation and setup steps, securing the OwnCloud installation with Let's Encrypt SSL/TLS ensures a secure browsing experience for users.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

Advertisement

📚 Related Tutorials

How to Install Nginx on Ubuntu Linux
Ubuntu Linux How to Install Nginx on Ubuntu Linux
How to Install FossBilling with Nginx on Ubuntu Linux
CMS How to Install FossBilling with Nginx on Ubuntu Linux
How to Install FreeScout with Nginx on Ubuntu Linux
CMS How to Install FreeScout with Nginx on Ubuntu Linux
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *