Hint: You can use the Tab key to autocomplete all filenames and directories, so you don't have to type in the complete file or directory name manually.
This tutorial was last checked and updated on December 21, 2020.
- If you havn't already done so, download the program "PuTTY".
- Connect to your root server or VPS/vServer via SSH using PuTTY. To do this, open PuTTY and enter the domain or IP address of your server in the text box named "Host Name (or IP address)". Then click the "OK" button below.
- Update your package lists with the command
- Now install any available updates of the packages already installed on your server using the command
apt upgrade -y.
- The installation of Nextcloud requires a web server as well as PHP and a database server. If you haven't already done these installations yet, install the Apache2 web server, PHP 7 and the MariaDB server. My tutorial for this installation can be found here.
- Go to the web directory to install Nextcloud there. By default, the web directory is located at "/var/www/html", so the command is
- Now use the command
wget https://download.nextcloud.com/server/releases/latest.tar.bz2to download Nextcloud.
- After the download is completed, you should see the downloaded .tar.bz2 archive using the command
ls. Extract this archive you just downloaded by executing the command
tar xfvj latest.tar.bz2.
- After unpacking this archive, you can delete it using the command
- For Nextcloud to work properly, the Apache2 module "mod_rewrite" must be activated. To do this, use the command
- Restart the Apache2 web server by executing the command
systemctl restart apache2.
- Now assign the required owner permissions for the Nextcloud directory to the web server user with the command
chown -R www-data:www-data /var/www/html/nextcloud/.
- After that you have to create the database needed for Nextcloud. To do this, visit phpMyAdmin in the web browser by appending "/phpmyadmin" to the IP address or domain of your server and log in to the MySQL server (as described in my Apache2 tutorial).
- Click on the "User accounts" tab on top of the page and then click on "Add user account".
- Now set a username (e.g. "nextcloud") and a password for the database user.
- After you've done that, you have to tick the checkbox for "Create database with same name and grant all privileges" so that the database user is created as well as the database itself. The database name will be the same as the username you specified.
- Then click on the "OK" button at the bottom of the page. Thus, you have created the database as well as the database user.
- Now go to Nextcloud in your web browser. The URL is the IP address or domain of your server, followed by "/nextcloud". The setup page appears.
- Create an administrator account for Nextcloud with which you can log in later. To do this, enter your desired username and password in the text fields "Username" and "Password".
- After that you have to enter the database username (e.g. "nextcloud"), the password for this user and the name of your Nextcloud database you previously created using phpMyAdmin (the same as the database username).
- Click on "Finish setup", to complete the installation.
- Now enable the use of ".htaccess" files by editing your Apache2 vHost configuration file. If you haven't created your own vHost and use it, the default vHost is used ("/etc/apache2/sites-available/000-default.conf"). Edit this file using the following command:
- In this configuration file, add the following content below the "DocumentRoot" line and replace "/var/www/html" with your DocumentRoot directory, if you use a directory other than the default one:
- Save your changes to the configuration by pressing CTRL + X, then hit the "Y" key followed by enter.
- Then run the command
systemctl reload apache2to reload the Apache2 web server.
- The installation and setup of your Nextcloud is now completed and you can start using it.