The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

May 20, 2018
The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

“The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server” covers the process of configuring an AWS EC2 instance as a Nextcloud server. Nextcloud is an open source, self-hosted solution to business, organization, and individual cloud storage and is similar to popular proprietary cloud storage solutions like Dropbox and OneDrive. Nextcloud allows users to safely and securely store data and backups remotely, providing access through a web interface like its proprietary counterparts. A folder sync feature is also available, making the process of syncing data between multiple machines as easy as dragging and dropping a file or folder into the sync folder. To make the deal even sweeter, Nextcloud clients are available for Windows, MacOS, Linux, Android, and iOS. This means that your data is accessible regardless of the device that you are using. Find out more about Nextcloud here.

1. This tutorial assumes that you have already created an Amazon AWS account and the associated SSH keys needed to access your instances. After logging in to AWS, navigate to the EC2 Management Console and click the blue “Launch Instance” button.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

2. The page displayed after clicking the “Launch Instance” button displays a list of operating systems that can be installed. For this project, we are choosing “Ubuntu Server 16.04 LTS (HVM), SSD Volume Type.” This AMI, or Amazon Machine Image, is perfect for the project and qualifies for the free tier.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

3. Next, we are prompted to choose the instance types. Instance types vary wildly in resources like RAM, vCPUs, and network performance. For the purpose of this project, the t2.micro instance type will suffice. Make sure that the t2.micro instance type’s box is checked and click the blue “Review and Launch” button on the bottom right of the page.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

4. Now we can view a summary of our new instance. We will now need to click on the blue “Edit security groups” link on the right of the page.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

5. The Security Groups page opens and we can now see the firewall rules for our instance. We will need to allow HTTP and HTTPS access to our Nextcloud server so click the grey “Add Rule” button on the left side of the page.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

6. A new row appears. From the dropdown on the left of the new row, choose HTTP. Click the grey “Add Rule” button again and choose HTTPS from the dropdown this time. The result should look like this:

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

7. Click the blue “Review and Launch” button at the bottom right of the page. We are taken back to the summary of our new EC2 instance and can now safely click the blue “Launch” button on the bottom right of the page.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

8. Now we must choose the SSH key pair that we will use to remotely access our Nextcloud server. Choose your selection from the dropdowns and check the acknowledgment box under the dropdowns. Then click the blue “Launch Instances” button on the bottom right of the modal.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

9. After launching the instance, the Launch Status page is displayed. We can click the blue “View Instances” button on the bottom right of the page.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

10. We are now returned to the EC2 Management Console where we can view the status of the instance. The instance will not be available for a few moments as the initial setup is underway. Under the Status Checks column of the console, if an hourglass and the word “Initializing” are present, the instance is not accessible. However, when the cell has a green circle and the phrase “2/2 checks...”, the instance can be accessed via SSH.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

11. We now need to configure a static IP for our Nextcloud server. In the pane on the left of the EC2 Management Console, locate the section named “Network and Security” and choose the “Elastic IPs” option. At the top of the page that renders, click the blue “Allocate new address” button at the top right of the console.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

12. Now we click the blue “Allocate” button.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

13. If all goes well, a green success box is displayed with our new IP address within it. We can safely click the blue “Close” button.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

14. Now that we have allocated a new, static IP address, we have to associate it with our EC2 instance. Make sure that the box is checked next to our newly assigned static IP address and click the grey “Actions” button at the top left of the console and navigate to “Associate address” from the dropdown.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

15. From the “Instance” dropdown, choose the new EC2 instance that we just made and choose a Private IP from the “Private IP” dropdown menu. Once completed, click the blue “Associate” button to continue.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

16. A green success box will now be displayed if our configuration was correct. We can safely click the blue “Close” button.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

17. Copy the new static IP address to a text file and store it somewhere safe. You will need the IP address to access the instance. If your host machine is a Debian or Ubuntu machine, open a terminal and navigate to the directory where the SSH key for accessing the instance is. Enter the command:

ssh -i your-key.pem [email protected]

When asked about the authenticity of the host, type "yes" and press the Enter key on you keyboard.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

18. Sweet! We are now securely accessing our new EC2 instance via SSH. The output in your terminal should look similar to this:

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

19. Before we install Nextcloud, we need to make sure that our new instance is up-to-date. Enter the following command to update Ubuntu Server 16.04, then press the Enter key on your keyboard.

sudo apt-get update && sudo apt-get upgrade -y

20. Once updating is complete, we need to configure Ubuntu Firewall to allow HTTP, HTTPS, and SSH connections. First, enter the command:

sudo ufw enable

This command enables Ubuntu Server’s built-in firewall. The output of the command should look like:

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

21. Now we must allow OpenSSH access to the instance or we will be locked out. Enter the command:

sudo ufw allow OpenSSH

The output of the command should look like this:

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

22. Next, to allow HTTP and HTTPS access to the instance, enter the command:

sudo ufw allow 80,443/tcp

The output of the command should look like this:

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

23. Finally, we can view a summary of our Ubuntu Firewall rules by entering the following command:

sudo ufw status

The output of the command should look like this:

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

24. We are now finished configuring Ubuntu Firewall and can begin installing and configuring Nextcloud. We will install Nextcloud via snap as it is the easiest, most convenient, and fastest method of installing Nextcloud. First, enter the command:

sudo snap install nextcloud

The final output of the command should look like this:

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

25. We are now finished with the terminal for a moment and can access our new Nextcloud installation from a web browser. Open a browser and enter the IP address that we associated with our EC2 instance. We are greeted with the Nextcloud login page where we must configure and admin account. Enter a username and password for the admin account and click the “Finish Setup” button.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

26. Congrats! After setup is complete, you are granted access to your account and can begin to use Nextcloud as a cloud storage solution.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

27. BUT WAIT! Lets secure traffic to and from our Nextcloud server with HTTPS. This assumes that you already possess a FQDN, or “Fully Qualified Domain Name.” A FQDN is a top level domain like example.com or www.example.com. For this tutorial, I will use paragondevices.com as the example.

28. Depending on who your domain registrar is, the following steps may vary, but will be similar. GoDaddy is the domain registrar for paragondevices.com, so the following steps will be completed via GoDaddy. Visit your domain registrar’s website and login. Choose your domain name and locate where the domain name’s DNS settings are.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

29. Create a new A record with the Host as “nextcloud” and that points to the IP address that we configured for our Nextcloud server, then click “Save”.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

30. Now that our DNS settings are complete, we can access our Nextcloud server simply by entering nextcloud.your-domain-name.com. For example, my Nextcloud server is now available at nextcloud.paragondevices.com. Before we can use our Nextcloud server with this domain name, we have to add it as a trusted domain. Go ahead and click the button to allow the domain name as a trusted domain.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

31. We are now logged into the Nextcloud server, but must confirm the addition of our domain as a trusted domain. Click the blue “Yes” button to confirm.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

32. We are almost finished securing traffic to and from our Nextcloud server. We just need to install a HTTPS certificate and configure it to complete the process. First, return to the terminal and enter the command:

sudo nextcloud.enable-https lets-encrypt

You will be asked a few questions before the certificate is installed. When asked if you meet the requirements, enter “y” followed by the Enter key on your keyboard.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

Next, enter an email address for urgent notices or key recovery.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

Now we enter our domain names separated by a space and press the Enter key on the keyboard. For example, my Nextcloud server domain name is nextcloud.paragondevices.com.

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

If everything completes without an error, the output looks like this:

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server

33. Congratulations! We can now access our Nextcloud server securely via HTTPS. Enter https://nextcloud.your-domain-name.com into a web browser and you will be greeted with your Nextcloud server login page, this time via an https conncetion. Enter your credentials, login, and enjoy Nextcloud!

The Ultimate Guide to Creating a Nextcloud AWS EC2 Instance with Ubuntu 16.04 Server