Services like Dropbox make it easy for you to access your files on multiple devices. However, you might want more control over them. In less than 30 minutes, you can have your own cloud-syncing service up and running on a server you control via Nextcloud.
What Is Nextcloud?
Nextcloud is open-source software that allows you to sync files between your PC and other devices, just as you would with Dropbox, Onedrive, or Google Drive. In addition, Nextcloud has a vibrant app ecosystem that allows you to do more than just sync files. You can use Nextcloud for calendar and contact management or to run a web-based IMAP email client. You can even set up a live chat program exclusively for you and anyone else who can access your server.
Before we get into the details, though, there is a warning. Once you start using Nextcloud, it’s up to you to maintain the server. This means that in addition to managing the Nextcloud software, you have to make sure the underlying server operating system stays up to date with patches. Nextcloud servers are generally trouble-free, but if something does go wrong, it’s up to you to fix it.
The good news is there are heaps of blogs, forums, and help pages to assist you in troubleshooting. If you do encounter a problem, it’s likely happened to someone else and there’s a solution out there.
What You’ll Need
You’ll need the following three items to get started with Nextcloud:
- A virtual server running Ubuntu 18.04
- The Bash shell on your computer’s desktop.
- A domain name.
For our examples, we’ll create several usernames and passwords, including the following:
- The root username and password for your server.
- A regular server username and password with administrative privileges.
- A Nextcloud username and password.
For the purposes of this tutorial, we’re using a virtual server running Ubuntu 18.04 from DigitalOcean. You can use any provider you like, however, including Linode or AWS. Whichever service you choose, the key is to run Ubuntu 18.04 (the current long-term support release at this writing) to avoid any potential issues.
Every virtual server provider is a bit different, but they all aim to get a server up and running with a few mouse clicks. To start, we advise that you use a base-level server on a trial basis until you get used to Nextcloud. Digital Ocean’s $ 5 droplet offers 1 GB of RAM, 1 CPU core, 1 TB of data transfer, and 25 GB of storage. Linode offers a similar VPS for the same price.
Unless you’re comfortable with SSH keys, ask your provider for password-based root login details to start. After your server is running, and you’re comfortable with the command line, you can check your provider’s help pages on how to add SSH keys for a more secure login.
If your computer runs Windows 10, you’ll need to install the Windows Subsystem for Linux and get a Bash shell with Linux utilities to continue. If you use Linux or macOS, the Terminal program is all you need. Most Bash terminals come with SSH installed, but, if not, just type
sudo apt-get install ssh in the terminal window to install it.
When you buy a domain name, it doesn’t have to be a .COM address. Only you and your close friends and family will use it. For example, we found a .XYZ domain name for just $ 1 a year which will work just fine.
Prepping Your Server
To get your server ready for action, you need to set up a regular user account with administrative privileges. It’s a terrible, terrible idea to login as the all-powerful root user after the initial configuration.
By now, you should have an IP address and root password from your server provider. The IP address is how you connect to the server, and the password gets you in.
To start, type the following (replace the X’s with your server’s IP address), and then hit Enter:
Our IP address is 22.214.171.124, so we typed that in our command. If everything goes according to plan, the remote server (where you’ll put Nextcloud) will ask for a password. Type the password your server provider gave you.
You’ll then be asked to set a new password for root. Choose whatever you like, just don’t misplace or forget it!
You’re now inside your remote server, and it’s time to get to work. Press Enter after each command in this article to run it.
First, we type the following to add a new user to the server:
Replace “ian” with the username you want to use. Once you carry out this command, you’re asked to give the new user a password. After you do that, the rest of the information the server requests is optional; if you don’t want to provide it, just keep hitting Enter.
Next, we type the following to give our new user administrative privileges:
usermod -aG sudo ian
Again, replace “ian” with the username you chose previously.
Now, we open a second terminal window and type the following to make sure the new user accounts works:
Again, replace the above with your username and your server’s IP address. Type the password you created for this user account when prompted. If it works, go back to the terminal window in which you’re logged in as root.
Now, we type the following to make sure the Ubuntu firewall is working properly:
ufw allow OpenSSH
That last status command should return something like the image below, confirming that the firewall won’t block SSH.
You won’t see the “80, 443/tcp” part yet, but we’ll get to that later. Now, let’s close the root window and return to the second terminal window with the regular user.
There was a time when you had to configure and install the Nextcloud software, PHP, web server software, and database all separately.
It’s much easier to use the official Snap package, which takes care of everything with a single command. There’s no messing around with the database or need to worry if Apache or Nginx is serving your site.
If you want to see exactly what the Snap package installs (spoiler: it’s the rest of the LAMP stack, plus Redis), check out the Nextcloud snap repository on GitHub.
We type the following:
sudo snap install nextcloud
The “sudo” at the beginning elevates the regular user account so it has temporary administrative rights. You’ll be asked for your password to carry this out. If all goes well, in a minute or two, Nextcloud will be installed, and (almost) ready for action.
Next, we type the following to create a new Nextcloud user account that can log into our site:
sudo nextcloud.manual-install ianpaul correctHorseBatteryStaple
Instead of “ianpaul,” type the username you want to use to use log in to Nextcloud. The “correctHorseBatteryStaple” bit is our password. Don’t use it—it’s from a very well-known XKCD comic and is just an example.
Dealing with Domains
To make life easier, we don’t want to use an IP address all the time to access our server. Instead, we’ll use a domain name, which, again, you can get for as little as $ 1 per year. For our example, we’re using HowToGeekTest.xyz.
Once you have a domain, you’ll want to manage the DNS settings from your domain registrar (where you bought the domain) and point them at your server provider. If you chose DigitalOcean, for example, those settings would be ns1.digitalocean.com, ns2.digitalocean.com, and ns3.digitalocean.com.
Next, go to your server provider (for example, DigitalOcean, Linode, or whatever you chose), and add the new domain to your account. You’ll need to add an A record that points to your IP address, a CNAME record if you don’t want to use “www” all the time, and NS records if they weren’t added automatically.
The image below shows an example from DigitalOcean.
Technically, it can take up to 24 hours before your domain is available, but it usually starts working within a few minutes.
Back to Nextcloud
With the domain set up, we can get back to finishing Nextcloud in the terminal. If you logged out of the server with your regular user account (firstname.lastname@example.org in our example), log back in.
Now, we type the following to add our new domain to Nextcloud:
sudo nextcloud.occ config:system:set trusted_domains 1 --value=howtogeektest.xyz
After “–value=,” type your domain rather than ours (howtogeektest.xyz).
Next, we type the following to make sure our new domain was added properly:
sudo nextcloud.occ config:system:get trusted_domains
The terminal should print out something like the image below.
Next, we type the following make sure we can use the ports we want by letting them through the firewall:
sudo ufw allow 80,443/tcp
Port 80 is used by unencrypted HTTP traffic, while 443 is for SSL/TLS.
Speaking of which, we’re going to need a free SSL/TLS certificate from Let’s Encrypt, so we type the following:
sudo nextcloud.enable-https lets-encrypt
Once the Let’s Encrypt generator starts running, it asks for an email address and your Nextcloud domain name. Just follow the instructions and you should have a secure website certificate in no time. If Let’s Encrypt worked out, it’s time to test your setup.
Go to your new domain (like our howtogeektest.xyz). You should see a Nextcloud login page (see below) with a lock icon in the address bar.
If you see the login page, you’re ready to go. If not, wait a few hours and try again. If you’d like to troubleshoot right away, you can see if the server responds via IP address.
For this to work, we have to type the following, to add the IP address to our trusted domains:
sudo nextcloud.occ config:system:set trusted_domains 2 --value=126.96.36.199
Note that we used “trusted_domains 2” and not “trusted_domains 1.” If you just repeat “trusted_domains 1,” you’ll overwrite your actual domain name in the trusted domains list and won’t be able to use it.
Once that’s done, type the IP address in your browser’s address bar, and you should see the login page above. If not, something’s gone wrong with the installation.
Since we don’t have an SSL certificate for the IP address, it won’t be able to login securely. For that reason, we suggest you delete the IP from the trusted domains list after you confirm the server is working. To do this, type the following:
sudo nextcloud.occ config:system:delete trusted_domains 2
If your Nextcloud server isn’t performing well, you might need to increase the memory limit. By default, it’s 128 MB. To increase that to 512 MB, you’d log in to the server using the terminal and type the following:
sudo snap set nextcloud php.memory-limit=512M.
Now that Nextcloud is up and running, you can log in, peruse available apps, share files with others, and install Nextcloud on your desktop and mobile devices for multi-device syncing. Nextcloud offers desktop syncing tools and mobile apps for Windows, Mac, Linux, iPhone, iPad, and Android.
Welcome to your own personal drop box!