How to Install NextCloud Server on Ubuntu/Debian

Nextcloud is a self-hosted cloud platform that allows you to build your own private cloud with full control. Unlike public cloud storage services like Google Drive or Dropbox, with Nextcloud all your data is stored on your own server, ensuring security, privacy, and high customizability.

Key Features of Nextcloud:

  • File storage and sharing: Sync files across multiple devices and share securely with others.
  • Calendar and contacts management: Sync personal calendars, events, and contacts across devices.
  • Notes and task management: Create, edit notes, task lists, and reminders.
  • Extensibility: Install apps to add features such as chat, video calls, document editing, photo management, and more.
  • Advanced security: Supports data encryption, two-factor authentication (2FA), and detailed access control.
  • Access anywhere: Use Nextcloud via web browser, desktop apps, or mobile apps for convenient access to your data anytime, anywhere.

With Nextcloud, you not only have a private cloud but also enhance productivity, share data securely, and maintain flexibility. It’s an ideal solution for individuals, families, or small businesses looking for full data control without relying on third-party services

Preparation

Before starting, make sure your server is fully updated and has the LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) installed. Updating first helps prevent version conflicts and security issues.

sudo apt update && sudo apt upgrade -y

If you haven’t installed LAMP yet, It’s here : How to Install and Configure LAMP Stack on Ubuntu 23

Check Apache

First, make sure Apache is running on your server:

sudo systemctl status apache2

If the status shows active (running), Apache is up and running.

Check MySQL/MariaDB

Next, check the database service:

sudo systemctl status mysql

or

sudo systemctl status mariadb

If it’s not running, enable it before continuing.

Check PHP

php -v

If it displays the PHP version, PHP is ready. This is important because Nextcloud requires PHP to operate.

Install Required PHP Extensions

Before installing Nextcloud, you need to install the PHP extensions required by Nextcloud. This ensures all features like file sync, calendar sharing, and note management work properly.

sudo apt install -y php php-mysql php-gd php-xml php-mbstring php-curl php-zip php-intl php-bcmath php-gmp libapache2-mod-php unzip wget

Create a Database for Nextcloud

Before creating the database, make sure you remember the database name, user, and password you will use.

sudo mysql -u root -p

Create the database and user (replace nextcloud_db, nextcloud_db_user, and nextcloud_db_PWD with your own info):

CREATE DATABASE nextcloud_db;
CREATE USER nextcloud_db_user@localhost IDENTIFIED BY 'nextcloud_db_PWD';
GRANT ALL PRIVILEGES ON nextcloud_db.* TO nextcloud_db_user@localhost;
FLUSH PRIVILEGES;
EXIT;

Tip: Choose a strong password for better security.

Download and Install Nextcloud

Navigate to the Web Root

cd /var/www/html

This is where Apache will serve Nextcloud. Make sure this directory is empty or does not contain important files.

Download the Latest Nextcloud Version

wget https://download.nextcloud.com/server/releases/latest.zip

You can also check the official Nextcloud website for the newest version.

Unzip the Downloaded File

unzip latest.zip

After unzipping, you will see a new folder named nextcloud.

Set Permissions for the Nextcloud Directory

sudo chown -R www-data:www-data /var/www/html/nextcloud
sudo chmod -R 755 /var/www/html/nextcloud
ls -l /var/www/html/

Ensure the nextcloud folder is owned by www-data:www-data so Apache can access it properly.

Create a Virtual Host for Nextcloud

Before creating the Virtual Host, prepare your domain, subdomain, or IP address to access Nextcloud.

sudo vim /etc/apache2/sites-available/nextcloud.conf

Add the sample content:

<VirtualHost *:80>
ServerAdmin Your-Email
ServerName Domain_or_Subdomain_or_IP-Address
DocumentRoot /var/www/html/nextcloud

<Directory /var/www/html/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>

ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>

Remember to replace ServerAdmin with your email and ServerName with your domain, subdomain, or IP.

Enable Virtual Host and Required Apache Modules

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
sudo systemctl restart apache2

This ensures Nextcloud is served correctly and features like file sync and calendars work smoothly.

Complete Nextcloud Installation via Web Interface

Open your browser and navigate to your configured domain, subdomain, or IP.

Enter the username and password for the administrative account.

Enter the database name, database user, and database password you created earlier. Leave Storage & Database at the default settings.

Click Install to complete the setup. You can choose to install additional apps or click Skip and add them later.

Conclusion

Congratulations! You have successfully installed Nextcloud Server on Ubuntu/Debian. You can now store, share, and manage your private cloud safely and securely.

Video – How to Install NextCloud Server on Ubuntu

Leave a Reply

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