How to Install Nextcloud on Debian 9
Install PHP
Let’s start with the installation of PHP 5.6 or higher version on your Debian 9 Stretch system.
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
output:
root@vps:~# wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
OK
echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list
output:
root@vps:~# echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list
deb https://packages.sury.org/php/ stretch main
apt-get update
output:
root@vps:~# apt-get update
Get:1 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Ign:2 http://ftp.us.debian.org/debian stretch InRelease
Get:3 http://ftp.us.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:4 http://security.debian.org/debian-security stretch/updates/main Sources [188 kB]
apt-get install -y php php-gd php-curl php-zip php-xml php-mbstring
OUTPUT:
root@vps:~# apt-get install -y php php-gd php-curl php-zip php-xml php-mbstring
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
Install Apache2
apt-get install -y apache2 libapache2-mod-php
OUTPUT:
root@vps:~# apt-get install -y apache2 libapache2-mod-php
Reading package lists... Done
Building dependency tree
Reading state information... Done
apache2 is already the newest version (2.4.25-3+deb9u6).
Install MySQL
apt-get install -y mysql-server php-mysql
OUTPUT:
root@vps:~# apt-get install -y mysql-server php-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
Download Nextcloud Archive
Let’s download latest Nextcloud from its official website.
cd /tmp
wget https://download.nextcloud.com/server/releases/nextcloud-15.0.0.zip
output:
root@vps:/tmp# wget https://download.nextcloud.com/server/releases/nextcloud-15.0.0.zip
--2019-01-09 12:03:35-- https://download.nextcloud.com/server/releases/nextcloud-15.0.0.zip
Resolving download.nextcloud.com (download.nextcloud.com)... 88.198.160.133
Connecting to download.nextcloud.com (download.nextcloud.com)|88.198.160.133|:443... connected.
Now extract downloaded archive under website document root and setup appropriate permissions on files and directories.
Install unzip.
apt-get install unzip
output:
root@vps:/var/www/html# apt-get install unzip
Reading package lists... Done
Building dependency tree
Reading state information... Done
cd /var/www/html
sudo unzip /tmp/nextcloud-15.0.0.zip
output:
root@vps:/var/www/html# unzip /tmp/nextcloud-15.0.0.zip
Archive: /tmp/nextcloud-15.0.0.zip
chown -R www-data:www-data nextcloud
output:
root@vps:/var/www/html# chown -R www-data:www-data nextcloud
drwxr-xr-x 13 www-data www-data 4096 Jan 9 12:23 nextcloud
chmod -R 755 nextcloud
output:
root@vps:/var/www/html# chmod -R 755 nextcloud
drwxr-xr-x 13 www-data www-data 4096 Jan 9 12:23 nextcloud
Now,remove the archive file.
rm -f /tmp/nextcloud-15.0.0.zip
output:
root@vps:/var/www/html# rm -f /tmp/nextcloud-15.0.0.zip
Create MySQL Database
let’s create a MySQL database and user account for configuring Nextcloud.
Note,
- The database name here would be, nextcloud
- The database username would be, nextcloud
-
Replace 'PASSWORD' with a secure password.
mysql -u root -p
output:
root@vps:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
CREATE DATABASE nextcloud;
output:
MariaDB [(none)]> CREATE DATABASE nextcloud;
Query OK, 1 row affected (0.00 sec)
GRANT ALL ON nextcloud.* to 'nextcloud'@'localhost' IDENTIFIED BY 'PASSWORD';
output:
MariaDB [(none)]> GRANT ALL ON nextcloud.* to 'nextcloud'@'localhost' IDENTIFIED BY 'PASSWORD';
Query OK, 0 rows affected (0.00 sec)
FLUSH PRIVILEGES;
output:
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
Run Nextcloud Web Installer
http://localhost/nextcloud/