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 October 23, 2018.

Are you looking for very good, powerful and cheap servers? I've been renting my servers at Contabo for 5 years now and I can highly recommend Contabo to everyone!
  1. If you havn't already done so, download the program "PuTTY".
  2. 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.
  3. Update your package lists with the command apt-get update.
  4. Now install any available updates of the packages already installed on your server using the command apt-get upgrade -y.
  5. 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.
  6. Go to the web directory to install Nextcloud there. By default, the web directory is located at "/var/www/html", so the command is cd /var/www/html.
  7. Now use the command wget https://download.nextcloud.com/server/releases/latest.tar.bz2 to download Nextcloud.
  8. 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.
  9. After unpacking this archive, you can delete it using the command rm latest.tar.bz2.
  10. For Nextcloud to work properly, the Apache2 module "mod_rewrite" must be activated. To do this, use the command a2enmod rewrite.
  11. Restart the Apache2 web server by executing the command systemctl restart apache2.
  12. Now assign the required owner permissions for the Nextcloud directory the web server user with the command chown -R www-data:www-data /var/www/html/nextcloud/.
  13. 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).
  14. Click on the "User accounts" tab on top of the page and then click on "Add user account".
  15. Now set a username (e.g. "nextcloud") and a password for the database user.
  16. 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.
  17. Then click on the "OK" button at the bottom of the page. Thus, you have created the database as well as the database user.
  18. 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.
  19. 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".
  20. 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).
  21. Finally, click on "Finish setup", to complete the installation.
  22. The installation and setup of your Nextcloud is now completed and you can start using it.