is an open source, self-hosted file sharing and collaboration platform similar to Dropbox. It comes with a media player, calendar and contact management.
Nextcloud can be expanded via apps and offers desktop and mobile clients for all major platforms.
In this tutorial, we will show you how to install and configure Nextcloud with Apache on an Ubuntu 18.04 machine.
Before starting the tutorial, make sure you are logged in as a user with sudo permissions.
Step 1: create the MySQL database
NextCloud can use SQLite, PostgreSQL or MySQL databases to store all of its data. In this tutorial we will use MySQL as the database of choice.
If you don’t have MySQL or MariaDB installed on your Ubuntu server, you can install one of the following instructions:
- Install MySQL on Ubuntu 18.04
- Install MariaDB on Ubuntu 18.04
To create a database and user, first log into the MySQL shell by entering the following command:
Run the following SQL statements to create a database named. to create
nextcloud, User name
nextclouduser and to grant the user all necessary authorizations:
CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'change-with-strong-password';
Step 2: Install PHP and Apache
Nextcloud is a PHP application. PHP 7.2, the standard PHP version in Ubuntu 18.04, is fully supported and recommended for Nextcloud.
Run the following command to install Apache, PHP, and any required PHP extensions and:
sudo apt install apache2 php7.2 php7.2-gd php7.2-json php7.2-mysql php7.2-curl php7.2-mbstring php7.2-intl php7.2-imagick php7.2-xml php7.2-zip libapache2-mod-php7.2
Step 3: Configure the firewall
Assuming you use
To manage your firewall you need to use HTTP (
80) and HTTPS (
443) Ports. You can do this by enabling the “Apache Full” profile, which contains rules for both ports:
sudo ufw allow 'Apache Full'
Step 4: Download Nextcloud
At the time of this writing, the latest stable release of Nextcloud is version 15.0.0. Before proceeding to the next step, visit the Nextcloud download page
and check if a new version of Nextcloud is available.
First, download the latest version of Nextcloud using the following wget command:
wget https://download.nextcloud.com/server/releases/nextcloud-15.0.0.zip -P /tmp
As soon as the download is complete, unzip the archive to the / var / www directory:
sudo unzip /tmp/nextcloud-15.0.0.zip -d /var/www
Set the correct owner so that the Apache web server has full access to Nextcloud’s files and directories.
sudo chown -R www-data: /var/www/nextcloud
Step 5: configure Apache
Open your text editor and create the following Apache configuration file.
sudo nano /etc/apache2/conf-available/nextcloud.conf
Alias /nextcloud "/var/www/nextcloud/" <Directory /var/www/nextcloud/> Options +FollowSymlinks AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud </Directory>
Activate the newly added configuration and all required Apache modules with:
sudo a2enconf nextcloud
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
Activate the changes by restarting the Apache service:
sudo systemctl reload apache2
Step 6: Install Nextcloud
After Nextcloud has been downloaded and all required services have been configured, open your browser and start the Nextcloud installation by going to the domain name or IP address of your server followed by
You will be shown the Nextcloud setup page.
Enter your desired admin username and password as well as the MySQL user and database details created earlier.
click on the
Finish setup Button and once the installation process is complete, you will be redirected to the Nextcloud dashboard, which is logged in as an admin user.
You learned how to install and configure Nextcloud on your Ubuntu 18.04 computer. If you have linked a domain name to your Nextcloud server, you can follow these instructions and secure your Apache with Let’s Encrypt.
For more information on managing your Nextcloud instance, see Nextcloud documentation
If you have any questions please leave a comment below.