The Cloud can be a great thing. It can also be a terrifying Orwellian nightmare where some faceless corporate entity has every picture you’ve ever taken of your family. To prevent the latter, there’s Nextcloud.
You many have heard of Owncloud. It was the primary solution for open source self hosted cloud storage for quite some time. Unfortunately, due to internal struggles, Owncloud split. Owncloud still remains, but it is currently owned by the people that caused the split. Nextcloud, on the other hand, is run by the original founder and the people who wanted to continue to work with the open source community.
Before you start the Nextcloud install process, you should follow our other guide on setting up a LAMP server on Debian Stretch. Nextcloud is a PHP application that utilizes a database and works best when paired with Apache. Having a LAMP server set up will be the best starting point.
Before you install Nextcloud, you need a few more PHP packages. Nextcloud is a fairly large and complex PHP application and makes use of more features that Debian’s default PHP package makes available. To get them all, just run the command below.
# apt install php7.0-xml php7.0-cgi php7.0-cli php7.0-mysql php7.0-mbstring php7.0-gd php7.0-curl php7.0-zip
Once that completes, you need to restart Apache so it can recognize the changes in PHP.
# systemctl restart apache2
Create The Database
Nextcloud works with Squlite3, MySQL, and PostgreSQL. Since this guide is based on a LAMP stack, it’s going to use MySQL/MariaDB. You can use PostreSQL, if you want. Sqlite3 is not recommended.
Start off by signing in as your database’s root user.
# mysql -u root -p
Once in MySQL, you can create a new Nextcloud database.
CREATE DATABASE nextcloud;
Next, create a user. You can use an existing user and skip this step, if you would prefer.
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'yourpassword';
Finally, grant that new user all privileges on the Nextcloud database.
GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost';
Now, just flush the privileges and exit.
FLUSH PRIVILEGES; exit;
With everything else set up and ready to go, you can now download Nextcloud and install it. Nextcloud is provided as a zip or tarball instead of a package. That’s actually okay. It’s easier to install and manage that way.
Rather than going the graphical route, just
cd to your Downloads folder and get Nextcloud with
wget You can go graphical, but this guide isn’t going to cover it.
$ cd ~/Downloads $ wget https://download.nextcloud.com/server/releases/nextcloud-11.0.1.zip
Now, just unzip.
$ unzip nextcloud-11.0.1.zip
It’s finally time to stick that newly unzipped Nextcloud folder in your web root directory. You can copy it there as root.
# cp -r /home/user/Downloads/nextcloud /var/www/html/nextcloud
The folder permissions won’t be ideal for use. You need to make Apache’s user the owner of
nextcloud in order for it to be able to write your files to the directory. On Debian, that user is
chown -R www-data:www-data /var/www/html/nextcloud
You are now ready to install Nextcloud through its web installer.
Open up your browser, and navigate to
localhost/nextcloud. You should see a message asking you to create an admin user and connect to a database. Enter what you would like for your admin user.
For the database, you will either see three options, one for each possible database. If you haven’t installed the other two, you may just see MySQL. Either way, select MySQL. Enter in the database name, database user, and password for that user. Leave “localhost” as it is.
With all of the correct information entered, submit the form. Nextcloud will take care of the rest. You will be dropped into an interface displaying some demo files. Your Nextcloud installation is now ready to go!
That’s really all. Nextcloud’s interface is very simple and easy to navigate. Feel free to explore. The files that you upload are stored in the
data directory within the
nextcloud directory. If you need a ton of storage, it may be a good idea to put that folder on its own drive and use a symlink. It is also recommended that you use an SSL certificate(see our LetsEncrypt guide) to secure your Nextcloud server, if you’re using it on public facing server.