How to install Nextcloud 12.0 on Debian 9

Today we will learn how to install Nextcloud 12.0 on Debian 9 Stretch. The latest stable version of Nextcloud 12.0 is now available for download. Nextcloud is fork of Owncloud which is powerful and rich features of file sharing and storage. There are many updates, bug fixes and improvements have been made to Nextcloud 12.0. I am going to use the manual installation on this tutorial. Please make sure you have LAMP Server is up and running on your Debian 9.

How to install LAMP Server on Debian 9

System Information:

The following details are used in the this tutorial

  • OS: Debian 9 Stretch
  • IP address:

Steps to Install Nextcloud 12.0 on Debian 9

Step 1. Install required packages

Before we install Nextcloud, we need to install some packages needed by Nextcloud to run properly.

apt update
apt install php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip
systemctl reload apache2

Step 2. Download Nextcloud

cd /tmp

Step 3. Create MySQL Database

We will create a new database on MySQL Server to hold Nextcloud data

root@debian:/tmp# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 10.1.23-MariaDB-9+deb9u1 Debian 9.0

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database nextcloud;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user nextcloud@localhost identified by '12345';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> grant all privileges on nextcloud.* to nextcloud@localhost identified by '12345';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit;

Step 4. Extract Nextcloud compressed package

apt install unzip

Step 5. Move Nextcloud to Apache root directory

mv nextcloud /var/www/html/
chmod -R www-data:www-data /var/www/html/nextcloud

Step 6. Configure the Web Server

Create a configuration file

nano /etc/apache2/sites-available/nextcloud.conf

Now paste these lines

Alias /nextcloud "/var/www/html/nextcloud/"

<Directory /var/www/html/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off

 SetEnv HOME /var/www/html/nextcloud
 SetEnv HTTP_HOME /var/www/html/nextcloud


Close and save the file. Then, execute these commands

a2enmod rewrite
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime
systemctl restart apache2

At this point, our initial Nextcloud configuration is completed. Next we need to configure Nextcloud via Web browser.

Step 7. Configure Nextcloud

Open web browser and type the server IP address. In this case it would be:

install nextcloud 12.0 on debian 9

Now enjoy Nextcloud 12.0 on Debian 9.

Thanks for reading this how to install Nextcloud 12.0 on Debian 9 Stretch. Please consider share this post so everyone can get benefit from it.

1 Comment

  1. Thanks for this post.
    I think that the line
    chmod -R www-data:www-data /var/www/html/nextcloud
    should be
    chown -R www-data:www-data /var/www/html/nextcloud

2 Trackbacks / Pingbacks

  1. How to fix data directory warning on Nextcloud - Free Linux Tutorials
  2. como montar un servidor con debian utilizando virtualbox – diario de hackerman

Leave a Reply