How To Install Nextcloud on Debian 10
Install the Required Packages
Nextcloud is a PHP web application. It requires PHP, a web server (Apache), and a database (MariaDB).
apt install apache2 libapache2-mod-php mariadb-server php-xml php-cli php-cgi php-mysql php-mbstring php-gd php-curl php-zip
Output:
root@my:~# apt install apache2 libapache2-mod-php mariadb-server php-xml php-cli php-cgi php-mysql php-mbstring php-gd php-curl php-zip
Reading package lists... Done
Building dependency tree
Reading state information... Done
mariadb-server is already the newest version (1:10.3.18-0+deb10u1).
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils libapache2-mod-php7.3 libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libbrotli1 libcurl4
libjansson4 liblua5.2-0 libzip4 php7.3-cgi php7.3-curl php7.3-gd
php7.3-mbstring php7.3-xml php7.3-zip ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom www-browser
php-pear openssl-blacklist
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php
libapache2-mod-php7.3 libapr1 libaprutil1 libaprutil1-dbd-sqlite3
After that's finished, restart Apache and check the status.
systemctl restart apache2.service
systemctl status apache2.service
Output:
root@my:~# systemctl restart apache2.service
root@my:~# systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset:
Active: active (running) since Sat 2019-12-14 14:57:29 EST; 4s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 27276 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCC
Main PID: 27280 (apache2)
Tasks: 6 (limit: 2359)
Memory: 14.6M
Set Up Your Database
Set up a new root password when asked. You can accept the defaults for everything.
mysql_secure_installation
Sign in to MariaDB using the root password that you just set.
mysql -u root -p
Create a new database to use with Nextcloud.
CREATE DATABASE nextcloud;
Set up a new database user to access your Nextcloud database.
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'password';
Grant the permissions for the nextclouduser to access the database.
GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost';
Flush the privileges and exit MariaDB.
FLUSH PRIVILEGES;
Download Nextcloud
wget https://download.nextcloud.com/server/releases/nextcloud-16.0.1.zip
Output:
root@my# wget https://download.nextcloud.com/server/releases/nextcloud-16.0.1.zip
--2019-12-14 15:11:53-- https://download.nextcloud.com/server/releases/nextcloud-16.0.1.zip
Resolving download.nextcloud.com (download.nextcloud.com)... 176.9.217.52, 2a01:4f8:130:32f1::52
Connecting to download.nextcloud.com (download.nextcloud.com)|176.9.217.52|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 121671144 (116M) [application/zip]
Saving to: ‘nextcloud-16.0.1.zip’
nextcloud-16.0.1.zi 100%[===================>] 116.03M 94.3MB/s in 1.2s
2019-12-14 15:11:54 (94.3 MB/s) - ‘nextcloud-16.0.1.zip’ saved [121671144/121671144]
Install Nextcloud
Unzip the Nextcloud zip file where it is.
unzip nextcloud-*.zip
Copy the extracted folder into your web root directory.
cp -r /home/user/nextcloud /var/www/html/nextcloud
Change the ownership of nextcloud to www-data, the same user running Apache.
chown -R www-data:www-data /var/www/html/nextcloud
Open the browser, and navigate to your Nextcloud server: http://Server_IP/nextcloud.
http://Server_IP/nextcloud