How to Install ownCloud with Nginx on Ubuntu 24.04
ownCloud with Nginx on Ubuntu 24.04 provides your own private cloud storage.
ownCloud is free software that lets you sync and share files securely, so you keep full control of your information.
Nginx is a very fast web server that works great for running your ownCloud setup. This guide shows you how to install ownCloud, specifically version 10.13.1, and set up Nginx on Ubuntu 24.04.
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.
Install Nginx HTTP server on Ubuntu
Install Nginx on Ubuntu to host your ownCloud files and handle user requests. Open your terminal and run ‘sudo apt update’ then ‘sudo apt install nginx’. This web server is a key step for your ownCloud setup on Ubuntu.
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.
http://localhost

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.
Install MariaDB database server on Ubuntu Linux
Install the MariaDB database server on Ubuntu Linux to give ownCloud a place to store its data. Open your terminal and run ‘sudo apt update’ then ‘sudo apt install mariadb-server’. This sets up the database system ownCloud will use.
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.
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.
- How to install MariaDB on Ubuntu Linux
- MariaDB without password prompt
Create an ownCloud database
Create a specific database and user for ownCloud within MariaDB to keep things organized and secure. We will name the database ‘ownclouddb’ and the user ‘ownclouddbuser’. This ensures ownCloud has its own dedicated space on the database server.
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:
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
Ensure to replace ‘type_your_password_here ‘with your password.
Install PHP-FPM on Ubuntu Linux
ownCloud needs PHP-FPM to work correctly on Ubuntu Linux, so install PHP 7.4-FPM using your terminal. It’s important to use version 7.4 as newer versions like PHP 8.x might not be compatible yet. Always check ownCloud’s requirements for the correct PHP version.
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
Download ownCloud files
Download the ownCloud application files to start setting up your personal cloud storage on Ubuntu Linux. Visit the official ownCloud download page to get the most recent version. You will then move these downloaded files to the correct folder on your server.
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
Secure your ownCloud connection with Nginx on Ubuntu by setting up a free Let’s Encrypt SSL/TLS certificate. This encryption keeps your data safe when accessed online. Follow the instructions to generate and install the certificate for your ownCloud server.
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.

Your ownCloud site should be ready to use.

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?
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.
No comments yet — be the first to share your thoughts!