How to Install ownCloud with Apache on Ubuntu 24.04
ownCloud is free software for sharing and syncing documents across all your devices without relying on third-party cloud services. Running it on Ubuntu 24.04 with the Apache web server gives you private cloud storage that stays under your control.
You need root access (or a user with sudo rights) on your Ubuntu server and a basic working knowledge of the command line. The setup has four main parts: Apache as the web server, MariaDB as the database, PHP 7.4 as the runtime, and the ownCloud files themselves. If you want to reach the site from outside your network, make sure ports 80 and 443 are open on your firewall and router. For the Let’s Encrypt step later, you also need a domain name that points to the server.
Install Apache, MariaDB, and PHP using apt commands. Create an ownCloud database in MariaDB, then download and extract the ownCloud files to the Apache web root directory.
Install Apache HTTP server on Ubuntu
Apache is the web server that receives requests and hands ownCloud’s pages to your browser. Install it first, then confirm it runs.
- Open a terminal on your Ubuntu server.
- Run sudo apt update to refresh the package lists.
- Run sudo apt install apache2 to install the web server.
- Start the service and check its status to make sure Apache runs correctly. The commands for this are in the steps below.
Open the Ubuntu terminal and run the commands below to install the Apache web server. Type your sudo password if asked. Nothing shows on screen while you type it, which is normal.
sudo apt update
sudo apt install apache2
Once Apache is installed, use the commands below to start it, stop it, and enable it so it starts automatically when your server boots. Enabling it matters. Without it, ownCloud goes offline after every reboot until you start Apache by hand.
sudo systemctl stop apache2
sudo systemctl start apache2
sudo systemctl enable apache2
To test that the Apache web server is running, open a web browser and browse to the server’s localhost or IP address. If you work on the server itself, use localhost. If you work from another computer, use the server’s IP address.
http://localhost

When you see the Apache2 Default Page, the Apache HTTP server is installed and working. If the page does not load from another computer, check that the service is running and that your firewall allows traffic on port 80.
Additional help on installing Apache on Ubuntu is in the link below.
Install MariaDB database server on Ubuntu Linux
MariaDB stores ownCloud's user accounts, file records, and app data. Installing it takes one command, but you should also secure it before you create the ownCloud database.
- In the terminal, run sudo apt install mariadb-server mariadb-client.
- When the installation completes, run the security script to protect the database installation. It lets you set a root password, remove anonymous users, and remove the test database. Do this before you create your ownCloud database.
The steps below install MariaDB, start it, and check that it works.
Open the Ubuntu terminal and run the commands below to install the MariaDB database server.
sudo apt update sudo apt install mariadb-server
Once MariaDB is installed, use the commands below to stop, start, and enable the server so it starts automatically when the machine boots.
sudo systemctl stop mariadb sudo systemctl start mariadb sudo systemctl enable mariadb
Run the following commands to confirm the MariaDB server is installed and responding.
sudo mariadb
When you run the commands above, they 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)]>
This message tells you the server is installed and accepting logins. If you get an error instead, check that the MariaDB service is running.
Additional help on installing MariaDB.
- How to install MariaDB on Ubuntu Linux
- MariaDB without password prompt
Create an ownCloud database
ownCloud needs its own database and a dedicated database user. Do not let it use the MariaDB root account. A separate user limits the damage if the web app is ever compromised. Log into the MariaDB prompt as root and run these statements in order:
- CREATE DATABASE ownclouddb; creates the empty database.
- CREATE USER 'ownclouddbuser'@'localhost' IDENTIFIED BY 'your_password'; creates the user.
- GRANT ALL PRIVILEGES ON ownclouddb.* TO 'ownclouddbuser'@'localhost'; gives that user full permissions on the new database only, so ownCloud can save its data.
In this guide, we create a database named ownclouddb and a user account called ownclouddbuser. You can use other names, but remember them for the setup wizard at the end.
Finally, we grant ownclouddbuser full access to the ownclouddb database.
You can do all of the database steps above with the commands below.
First, log on to the MariaDB database server:
sudo mariadb
The prompt changes to the MariaDB prompt. 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
Replace type_your_password_here with your own password. Use a long, unique one, and keep it somewhere safe. You will enter it again in the ownCloud setup wizard. Every statement must end with a semicolon, or MariaDB waits for more input.
Install PHP on Ubuntu Linux
ownCloud needs specific PHP modules to work with your database and web server. To install them, add the required PHP repository first, then run sudo apt install php7.4 libapache2-mod-php7.4 php7.4-mysql php7.4-xml php7.4-curl. Ubuntu 24.04 ships a newer PHP in its default repositories, so PHP 7.4 is not available until you add the extra repository in the steps below. Always check which PHP version your ownCloud release supports before you start.
ownCloud runs with PHP 7.4, but PHP 8.x is not currently supported by the release this guide uses. Check the PHP requirements page for your ownCloud version and install the newest PHP version it lists as compatible.
Run the commands below to install PHP 7.4.
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. This installs the Apache module and the extensions ownCloud needs.
sudo apt install php7.4 libapache2-mod-php7.4 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-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
With the server stack ready, get the ownCloud files and put them where Apache can serve them.
- Visit the official ownCloud website and copy the link for the latest archive file.
- Use the wget command in your terminal to download the tarball directly to your server.
- Extract the downloaded files with the tar command.
- Move the resulting folder into your Apache web root directory so the server can display it.
Always check the download page for the latest release. The download link in the commands below will go out of date, so replace it with the current one to get the latest version.
First, go to the /tmp directory and download the ownCloud files. After you extract the archive, move the contents into the ownCloud folder in the Apache root directory.
The last step is to change the ownership and permissions. This lets the Apache web server, which runs as the www-data user on Ubuntu, read and write the files it needs while the rest of the system stays protected. If you skip this step, the setup wizard later fails with permission errors.
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 the files are in place, configure Apache to serve the ownCloud content.
Run the command below to create an Apache virtual host file for ownCloud. It opens a new, empty file in a text editor.
sudo nano /etc/apache2/sites-available/owncloud.conf
Then copy and paste the content block below into the file. Change the server name and any other placeholder values to your own domain name or the server's IP address.
Alias /owncloud "/var/www/owncloud/"
<Directory /var/www/owncloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/owncloud
SetEnv HTTP_HOME /var/www/owncloud
</Directory>
Save the file and close the editor. In nano, press Ctrl+O, then Enter to save, and Ctrl+X to exit.
- Enable the virtual host for ownCloud by running sudo a2ensite owncloud.conf.
- Restart the Apache web server to apply the change by running sudo systemctl restart apache2.
If Apache fails to restart, read the error it prints. It usually points to a typo in the virtual host file or a missing Apache module, which you can enable with a2enmod.
sudo a2ensite owncloud.conf
sudo a2enmod env rewrite dir mime headers setenvif ssl
sudo systemctl restart apache2
Setup Let's Encrypt SSL/TLS for ownCloud
Without encryption, your ownCloud passwords and files cross the network in plain text. Let's Encrypt provides free certificates to fix that. Install the Certbot tool from your terminal, then run its Apache plugin command. Certbot requests the certificate and updates your Apache configuration to force HTTPS connections.
Certbot needs a real domain name that points to your server, and port 80 must be reachable from the internet so Let's Encrypt can verify the domain. Let's Encrypt certificates expire after 90 days, and Certbot normally sets up automatic renewal for you.
Please read the post below for more on installing and creating Let's Encrypt SSL certificates for Apache.
How to set up Let's Encrypt SSL certificate for Apache on Ubuntu Linux
Once you have restarted the Apache web server, open your browser and browse to the server hostname or IP address defined in the Apache virtual host file.
http://localhost/owncloud
The ownCloud installation wizard should appear. If you see the Apache default page or an error instead, check that the virtual host is enabled and the files are in the right folder. Fill in the wizard like this:
- Create an administrator account and password.
- Enter the database name, database account name, and password you created earlier. If the wizard asks for the database type, choose MySQL/MariaDB, and use localhost as the host.
- Click Finish setup.

When the wizard finishes, you land on the ownCloud login page. Sign in with the administrator account you just created, and your ownCloud site is ready to use.

Set up a reverse proxy for ownCloud
This step is optional. A reverse proxy lets you reach ownCloud through a friendly domain name instead of an IP address. To set one up with Apache, enable the proxy modules using sudo a2enmod proxy proxy_http. Then create a new virtual host configuration file that points your domain name to the local port where ownCloud listens. Restart Apache after you save the file so the change takes effect.
The links below should help you set that up.
That should do it!
Conclusion:
- Installing ownCloud with Apache on Ubuntu 24.04 gives you a private file-sharing and sync server that you control, running on a stable and widely used web server.
- This guide walked through installing the required components: the Apache HTTP server, the MariaDB database server, and PHP on Ubuntu Linux.
- It also covered creating the ownCloud database, downloading the ownCloud files, setting up Let's Encrypt SSL/TLS for your ownCloud site, and optionally setting up a reverse proxy with Nginx or Apache.
- If you follow the steps in order and use the linked resources where you need more detail, you end up with a working ownCloud site served by Apache on Ubuntu.
Have a question about this guide?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!