Self-Hosting Your Own Cloud Storage on AWS using NextCloud
Tags: cloud, aws, beginners, tutorial
Published: 2023-07-27 11:51:31

## Introduction

Ever thought of self-hosting your own private cloud server?? Nextcloud is a popular open-source file hosting and sharing platform that allows you to store, sync, and share your files, contacts, calendars, and more. Feel free to checkout the below video I made for this tutorial as well.

{% youtube i7q8JbNK-9s %}

In this tutorial, we will walk you through the process of self-hosting Nextcloud on AWS using EC2 and the snap package of Nextcloud.

![nextcloud-landingpage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsjs76h8wffei5fehs90.png)

## Prerequisites:

Before getting started, you will need the following:

1. An AWS account: Sign up for an AWS account if you don't have one already.
2. Basic knowledge of AWS services, particularly EC2.
3. Familiarity with Linux command line and server administration.
4. A domain name (optional): You can use a domain name to access your Nextcloud instance.

### Step 1: Launch an EC2 Instance:

Log in to your AWS Management Console. Navigate to the EC2 service. Select the region closest to you.

![aws-region](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ehbp5675tppf1u8fgvkn.png)

Launch a new EC2 instance, choosing an appropriate Amazon Machine Image (AMI) based on your preferred Linux distribution (e.g., Ubuntu, CentOS). Select the desired instance type, storage options, and security group settings.

![aws-instancesettings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gri27niyctwe4h0b9zni.png)

![aws-cloudcmd](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/folo2q1yxpaqp7lz7cup.png)

Make sure to enable **HTTP** and **HTTPS** along with **SSH**

![aws-network](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gi37tq4g190rcv48i5a0.png)

![aws-launch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zxyhdb1htl6ujwmflgo.png)

Create or select an existing key pair to access your EC2 instance securely.
Launch the instance and wait for it to be ready.

### Step 2: Connect to your EC2 Instance:

Obtain the public IP address or public DNS of your EC2 instance from the EC2 management console or use the web console by AWS.

Open a terminal or SSH client and connect to your EC2 instance using the following command:

```ssh -i <path_to_key_pair_file> <username>@<public_ip_or_dns>```

### Step 3: Install Nextcloud via Snap Package:

Update and Upgrade the package lists on your EC2 instance:

```sudo apt update && sudo apt upgrade -y```

Install the snap package management system:

```sudo apt install snapd```
Install Nextcloud snap package:

```sudo snap install nextcloud```

![snapd-nextcloud](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/um6y4gyljedf8rotcshn.png)

Replace `<username>` with the username you want to set and replace `<password>` with the password you want to set. Make sure to remove `<>` while typing.

```sudo nextcloud.manual-install <username> <password>```

Wait for the installation to complete. Nextcloud and its dependencies will be automatically installed.

![nextcloud-snap-install](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xuoxgqgv1auk9bunp7i.png)

### Step 4: Configure Nextcloud:

Now set the IP address/domain name you want to use to access your NextCloud server. You will need to add trusted domains through which it can be accessed.

Replace `<domain name>` with the domain name/IP address you want to set. Make sure to remove `<>` while typing.

**Set Trusted Domains**

```sudo nextcloud.occ config:system:set trusted domains 1 --value=<domain name>```

**Get Trusted Domains**

```sudo nextcloud.occ config:system:get trusted domains```

![nextcloud-trusted-domains](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ww3tpb7ftj44sq87ia2.png)

### Step 5: Finalize NextCloud

Open your web browser and enter the public IP address or DNS of your EC2 instance.

![nextcloud-homepage-ec2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/23z0ka8hqpeisw7sbi4a.png)

Complete the initial setup wizard, providing the required information such as admin username, password, and database configuration.

![nextcloud-files-page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdlxo0k4xcdwawc48r7h.png)

Customize Nextcloud settings according to your preferences, including storage location, external storage options, and encryption settings.

## Conclusion

Congratulations! 🎉 You have successfully self-hosted Nextcloud on AWS EC2 using the snap package. With Nextcloud, you have full control over your data and can enjoy secure file hosting, sharing, and collaboration features. Enjoy the benefits of self-hosted cloud storage with Nextcloud on AWS!

Thank you for reading! If you found this blog post helpful, please consider sharing it with others who might benefit. Feel free to check out my other blog posts and visit my socials!

- [Profile](https://bio.link/devarshishimpi)
- [Linkedin](https://linkedin.com/in/devarshi-shimpi)
- [Twitter](https://twitter.com/devarshishimpi)
- [Youtube](https://youtube.com/@devarshishimpi)
- [Hashnode](https://devarshishimpi.hashnode.dev)
- [DEV](https://dev.to/devarshishimpi)

### Read more

- [Easiest Way to Install WordPress Locally for Beginners](https://blog.devarshi.dev/easiest-way-to-install-wordpress-for-beginners)
- [Complete Markdown Tutorial for Beginners](https://blog.devarshi.dev/complete-markdown-tutorial-for-beginners)
- [Creating Your First Droplet - DigitalOcean Tutorials](https://blog.devarshi.dev/creating-your-first-droplet-digitalocean-tutorials)