Share your love
Run Nextcloud on Ubuntu 24.04 – Complete and Easy Guide
This guide intends to teach you to Install and Run Nextcloud on Ubuntu 24.04. As you may know, Nextcloud is a popular platform for file sharing and team collaboration. Also, you can use it to store files. Nextcloud is a free and open-source tool that you can use on Linux, Windows, and Mobile apps like Android and iOS.
By following the guide steps below from the Orcacore team, you can simply run Nextcloud on Ubuntu 24.04. Let’s see how you can do it.
Table of Contents
Easy Steps To Install and Run Nextcloud on Ubuntu 24.04
Before you start to run Nextcloud on Ubuntu 24.04, you need some requirements:
First, you must have access to your server as a non-root user with sudo privileges and a basic UFW firewall. To enable UFW on Ubuntu 24.04, you can check this guide on Basic UFW Firewall Configuration on Ubuntu 24.04.
In this guide, we use LAMP Stack to set up Nextcloud. To set up LAMP Stack, you can also check this guide on LAMP Stack Installation on Ubuntu 24.04.
Also, you need a domain name that is pointed to your server’s IP address.
Once you are done with these, follow the steps below to Run Nextcloud on Ubuntu 24.04.
Step 1 – Install PHP Extensions For Nextcloud on Ubuntu 24.04
To run Nextcloud on Ubuntu 24.04, you must install some PHP extensions on your server. To do this, you can run the command below:
sudo apt install php-{cli,xml,zip,curl,gd,cgi,mysql,mbstring,fpm} -y
Then, you need to enable the PHP FPM and restart your Apache service by using the following commands:
# sudo a2enmod proxy_fcgi setenvif
# sudo a2enconf php8.3-fpm
# sudo systemctl restart apache2
Step 2 – Create a Database and User For Nextcloud on Ubuntu 24.04
To run Nextclould on Ubuntu 24.04, you must create a database and database user for Nextcloud. To do this, you must log in to your MariaDB shell that you have configured in the LAMP Stack installation:
sudo mysql -u root -p
Now you need to create a database user with a strong password for Nextcloud. To do this, you can use the following command:
MariaDB [(none)]> CREATE USER 'nextcloud-user'@'localhost' IDENTIFIED BY "password";
Then, create a database for Nextcloud with the following command:
MariaDB [(none)]> CREATE DATABASE nextclouddb;
Next, you must grant all the privileges on your Netxtcloud database to your Netxcloud user with the following command:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextclouddb.* TO 'nextcloud-user'@'localhost';
Finally, flush the privileges and exit from your MariaDB shell with the following commands:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> Exit;
Step 3 – Download the Latest Nextcloud Package on Ubuntu 24.04
To run Nextcloud on Ubuntu 24.04, you must visit the official site and get the latest Nextcloud server package.
For downloading the Nextcloud package, you can use the following command:
sudo wget https://download.nextcloud.com/server/releases/latest.zip
Once your download is completed, you must unzip your downloaded file, move the extracted file to the /var/www/html/ directory, and set the correct ownership for your Nextcloud directory. To do this, run the following commands:
# sudo unzip latest.zip
# sudo mv nextcloud/ /var/www/html/
# sudo chown -R www-data:www-data /var/www/html/nextcloud
Step 4 – Set up VirtualHost for Nextcloud on Ubuntu 24.04
At this point, you need to create an Apache configuration file for Nextcloud. You can create and open your file with your favorite text editor like Vi Editor or Nano Editor:
sudo vi /etc/apache2/sites-available/nextcloud.conf
Add the following content to your file with your domain name:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/nextcloud
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/nextcloud/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/nextcloud/>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php [PT,L]
</Directory>
</VirtualHost>
When you are done, save and close the file.
Then, you must disable the default Apache configuration and enable the new one you have created above. To this, run the following commands:
# sudo a2dissite 000-default.conf
# sudo a2ensite nextcloud.conf
Next, enable the following modules and restart the Apache service to apply the changes:
# sudo a2enmod headers rewrite env dir mime
# sudo systemctl restart apache2
Step 4 – Access the Nextcloud Web Installer on Ubuntu 24.04
To run Nextcloud on Ubuntu 24.04, you must access the web installer and finish your Nextcloud installation. You must open your favorite browser and follow the below URL to access the Web installer:
http://your-server-ip-address
or
http://your-domain.com
You will see the following screen. You need to create an Admin user and password and then enter the details of the Database you have created. Finally, click Install.
Now you have access to NextCloud Dashboard to store your data.
That’s it, you are done. You have learned to install and run Nextcloud on Ubuntu 24.04.
Conclusion
Nextcloud is an open-source platform for hosting your cloud services like file storage, calendars, and contacts. As you saw, installing and configuring Nextcloud is easy by using the LAMP stack. You can follow the simple guide steps and run Nextcloud on Ubuntu 24.04.
Hope you enjoy using it. Also, you may like to read the following articles:
Install Nextcloud with LAMP stack on Debian 12
Step-by-Step Install Nextcloud on Rocky Linux 9
Install and Configure Nextcloud on AlmaLinux 9
Add External Storage to Nextcloud with Amazon S3 Bucket
FAQs
Which web server should I use for Nextcloud on Ubuntu 24.04: Apache or Nginx?
Both Apache and Nginx are compatible with Nextcloud. But Apache has better integration with PHP modules and easier configuration.
Which database should I use for Nextcloud on Ubuntu 24.04?
Nextcloud supports both MySQL and MariaDB. MariaDB has better performance and efficiency, especially for larger deployments.
Can I run Nextcloud on a private network with no internet access?
Yes, you can run Nextcloud entirely on a private network without the internet. However, if you want external access, you’ll need to configure port forwarding and DNS settings.