This article explains how to install ownCloud with Nginx support on Ubuntu 24.04.
Installing ownCloud with Nginx support on Ubuntu is essential because Nginx is a highly efficient web server that can handle many concurrent connections and is known for its low memory usage.
This makes it an excellent choice for serving ownCloud, a file hosting service that requires reliable and responsive web hosting. Using Nginx with ownCloud ensures fast and stable performance for file sharing and synchronization needs.
The steps below walk you through installing ownCloud with Nginx support on Ubuntu 24.04.
Install Nginx HTTP server on Ubuntu
ownCloud requires a web server. This post will install and use the Nginx web server to run ownCloud.
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.
How to install Nginx on Ubuntu
Install MariaDB database server on Ubuntu Linux
The next component required to run ownCloud is a database server. This post will install and use the MariaDB database server to run ownCloud.
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.
Create an ownCloud database
Upon successfully installing the MariaDB database server, create a blank database on the server specifically for the ownCloud application.
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
The last component you will need to run on your ownCloud is PHP-FPM. The ownCloud application is PHP-based and supports the latest versions of PHP.
ownCloud runs with the following PHP versions: 7.4. Note that PHP 8.x is currently not supported. Always check the PHP requirements page to ensure you’re installing the latest version.
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
Let’s begin by downloading and configuring ownCloud files on Ubuntu Linux.
Always 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.
Then, run the commands below to enable the server block and restart the Nginx server.
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
You may want to install an SSL/TLS certificate to secure your ownCloud site. Secure your ownCloud installation with HTTPS from Let’s Encrypt.
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.
Leave a Reply