1. Home
  2. Linux
  3. Debian
  4. How to install NextCloud 13 on Debian package 9

How to install NextCloud 13 on Debian package 9

How to install NextCloud 13 on Debian 9
How to install NextCloud 13 on Debian 9

Here, we’ll show you how to install NextCloud on Debian Package 9. before going into details lets have a look at what we have already discussed in previous articles;

  1. How to Install Buildbot on Debian 9
  2. Initial Server Setup with Debian

 

Nextcloud

Nextcloud is an open-source software suite that allows users to store their data, including files, contacts, calendars, news feeds, to-do lists, and much more on their personal servers.
It uses standard protocols such as webdavm, carddav, and caldav. It also provides client applications so that users can easily manage and synchronize their data among Linux, MacOS, and Windows platforms.
It makes Nextcloud a great free alternative to proprietary cloud services such as Dropbox, Google Drive, iCloud, etc…

 Install NextCloud  on Debian package 9

In this tutorial, we will install and configure Nextcloud 13 on a Debian 9 VPS with an Apache web server, PHP, and MariaDB.

Requirements

Before we start with the installation, there are several requirements your machine must meet:

  • 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

Log in to your Debian 9 VPS via SSH as 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, log in to the MariaDB server as 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. Combinations of letters and numbers and a minimum of 10 characters is recommended.

Download and install Nextcloud 4

Go to Nextcloud’s official website and download Nextcloud 13 to your Debian 9 VPS. Currently, the 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 that 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 the 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 successful, 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
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/nextcloud
ServerName domain.com
ServerAlias www.domain.com
Alias /nextcloud “/var/www/html/nextcloud/”
<Directory /var/www/html/nextcloud>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
</Directory>
ErrorLog /var/log/apache2/nextcloud-error_log
CustomLog /var/log/apache2/nextcloud-access_log common
</VirtualHost>

Save the file and enable the newly created virtual host:

a2ensite domain.com.conf

It is also recommended that you 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 complete. You can now visit http://domain.com and log in to your Nextcloud instance using the credentials used in the installation commands above.

Check out Our Best VPS Hosting for scaling your cloud-based applications and processes.

One more thing..
Don’t forget to subscribe to our email newsletter for more helpful tips, insights, and tutorials!

Updated on December 23, 2018

Was this article helpful?

Related Articles

Leave a Comment

[apsl-login-lite login_text='Please login with a social account']