HOW TO INSTALL NEXTCLOUD 13 ON DEBIAN 9

 In Dedicated, VPS, Web

REQUIREMENTS

Before we start with the installation there are several requirements:

  • SSH ‘root’ access to your server.
  • MySQL or MariaDB 5.5+; PostgreSQL version 9 or 10;
  • PHP version 7.0, 7.1 or 7.2.
  • Apache version 2.4 with mod_php or Nginx (php-fpm) web server

LOGIN VIA SSH AND UPDATE YOUR SYSTEM

Login to your Debian 9 VPS via SSH as user root

ssh root@IP_Address -p Port_Number

and make sure that all installed packages are up to date by running the following command

apt update && apt upgrade

INSTALL APACHE WEB SERVER

As mentioned in the requirements, a web server is required to run Nextcloud. Run the following command to install Apache on your VPS

apt install apache2

Once installed, start Apache and enable it to start at server boot

systemctl start apache2
systemctl enable apache2

INSTALL PHP

Install PHP and some PHP modules required by NextCloud

apt install php7.0 libapache2-mod-php7.0 php7.0-common php7.0-gd php7.0-json php7.0-mysql php7.0-curl php7.0-mbstring php7.0-intl php7.0-mcrypt php7.0-imagick php7.0-xml php7.0-zip

INSTALL MARIADB AND CREATE A DATABASE

Next, we will install MariaDB server using the following command

apt -y install mariadb-server

Start the database server and enable it to start upon server boot

systemctl enable mariadb
systemctl start mariadb

Run the mysql_secure_installation post-installation script to harden the security of your MariaDB server and set a ‘root’ password. You can use the following options

mysql_secure_installation

Set root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Now, login to the MariaDB server as user root and create a new user and database for Nextcloud

mysql -u root -p

MariaDB [(none)]> CREATE DATABASE nextcloud;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud_user'@'localhost' IDENTIFIED BY 'PASSWORD';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

Don’t forget to replace ‘PASSWORD’ with an actual strong password. Combination of letters and numbers and minimum 10 characters long is recommended.

Download and install Nextcloud
Go go Nextcloud’s official website and download Nextcloud 13 to your Debian 9 VPS. Currently latest stable version is 13.0.1

wget https://download.nextcloud.com/server/releases/nextcloud-13.0.1.zip

Extract the downloaded ZIP archive in a directory Apache has access to, and change the ownership of the nextcloud directory to the web server user

unzip nextcloud-13.0.1.zip -d /var/www/html/
chown -R www-data:www-data /var/www/html/nextcloud/

Once all Nextcloud prerequisites are fulfilled, we can complete installation using the on-screen installation wizard or through the command line. We will complete the installation through the command line. Change the current working directory

cd /var/www/html/nextcloud

and execute the following command as the web server user

sudo -u www-data php occ  maintenance:install --database "mysql" --database-name "nextcloud"  --database-user "nextcloud_user" --database-pass "PASSWORD" --admin-user "admin" --admin-pass "PASSWORD"

Use the database information we created above and set a strong password for the Nextcloud ‘admin’ user.

If the installation is successfull you will get the following output

Nextcloud was successfully installed

Edit the config/config.php file and add domain.com as a trusted domain

nano config/config.php

 'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'domain.com',
  ),

CREATE APACHE VIRTUAL HOST

If you want to be able to access Nextcloud with a domain name, you will have to create a new virtual host. Create the following file

nano /etc/apache2/sites-available/domain.com.conf

ServerAdmin admin@domain.com
DocumentRoot /var/www/html/nextcloud
ServerName domain.com
ServerAlias www.domain.com

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

 Options +FollowSymlinks
 AllowOverride All


 Dav off
 

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


ErrorLog /var/log/apache2/nextcloud-error_log
CustomLog /var/log/apache2/nextcloud-access_log common

Save the file and enable the newly created virtual host

a2ensite domain.com.conf

It is also recommended to enable the mod_headers, mod_env, mod_dir and mod_mime Apache modules

a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime

To activate the new configuration, you need to run the following command

systemctl reload apache2

With this step the Nextcloud 13 installation is completed. You can now visit http://domain.com and login to your Nextcloud instance using the credentials used in the insallation command above.

Recommended Posts

Start typing and press Enter to search