Today we are going to be installing Nextcloud On Raspberry Pi 4. This is Episode 9 in our Raspberry Pi Series. If you haven’t watched our previous episodes then please do so first. This is so you can be up to date with this episode.
Nextcloud is an open-source self-hosted collaboration platform. It offers cloud features like Calendars, Contacts, file sharing and syncing. It also has an integrated app store where the system administrator can enable extra functionality like video conferencing and third-party API access.
Nextcloud is a fork of Owncloud. The Development team partied ways due to differing visions of where they wanted to take the platform. Nextclouds vision is to enable users to take back control over their data and communications from big data corporations.
Difficulty = Medium
Table of Contents
You will need to have followed our previous episodes in our Raspberry Pi Series but if you just want to follow this guide we will give an overview of what you should already have:
- A Raspberry Pi with Raspberry Pi OS installed.
- Secured Raspberry Pi.
- A Duckdns account. Or if you want to use your own Domain – A Domain name and a Cloudflare account. Both need a DDNS container installed in Docker and configured correctly.
- A CNAME subdomain set up in Cloudflare for your Nextcloud service that is resolving correctly and has “DNS only” set in Proxy status.
- Openmediavault, Docker and Portainer Installed.
- Nginx Proxy Manager Docker installed and configured to accept incoming connections.
- NGINX Proxy Manager Docker container installed with port 80 and 443 on your Router forwarded.
- A volume created in Openmediavault to be used for Nextcloud storage (Appdata folder).
- Big enough external hard drive to store Nextcloud data. See our recommended USB Hard Drives below.
Recommended USB Hard Drives:
|WD 1TB My Passport Portable External Hard Drive||WD 4 TB My Passport Portable External Hard Drive|
|USA Amazon Link:||USA Amazon Link:|
|UK Amazon Link:||UK Amazon Link:|
So without further ado we are going to get started installing Nextcloud On Raspberry Pi 4.
Step 1 – Create the application folders:
The first thing we will need to do is set up two folders in our Appdata folder on our shared folder. The first folder we will call “nextcloud” and the second folder will be called “nextclouddb”.
Connect to your Pi via SSH and navigate to your Appdata folder by using the “cd” command.
Now we will create our “nextcloud” folder using the “mkdir” command.
Now we will do the same for our “nextclouddb” database folder.
Step 2 – Create and deploy the Nextcloud Docker Stack.
Now both the folders needed have been created. Navigate to your Portainer interface and log in.
Once logged in click on “Stacks” in the left hand menu. Then click on “Add Stack“
Name your Stack anything that makes sense to you. In our example we named it “nextcloud“.
Copy the below docker-compose file and edit the values to match your configuration needs.
version: '2' services: db: image: yobasystems/alpine-mariadb:latest command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW restart: always volumes: - /YOUR/FILE/PATH:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=YOURROOTPASSWORD - MYSQL_PASSWORD=YOURPASSWORD - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud app: image: nextcloud ports: - 8181:80 links: - db volumes: - /YOUR/FILE/PATH:/var/www/html restart: always
Your stack should look similar to this:
When you have finished click on “Deploy the stack“. This can take some time to finish.
Once finished if you navigate to “Containers” on the left menu you should see two new containers.
One is the Nextcloud application and the other is the Nextcloud Maria database. You can check the logs by pressing the log button under “Quick actions” to check all is running correctly.
Step 3 – Adding Subdomain and Letsencrypt SSL certificate in NGINX Proxy Manager.
Now both containers are linked to communicate with each other it is now time to head to NGINX Proxy Manager to add the subdomain and container entry.
Once at the NPM dashboard click on “Proxy Hosts”
Then “Add Proxy Host“
Enter your subdomain under “Domain Names” and be sure to click “Add new ….” underneath so it saves the entry.
Navigate to Raspberry Pi’s IP address to “Forward Hostname/IP” section.
Then add the port you have assigned to the Nextcloud Docker. In our example we have used port “8181“.
Click the “Block Common Exploits” button so it turns green.
Your New proxy Host should now look similar to this:
Now press the “SSL” top menu.
Under “SSL Certificate” where it says “None” click then click on “Request a new SSL Certificate“
Click on “Force SSL“, “HTTP/2 Support” and “I agree to the Let’s Encrypt Terms of Service“. Then click Save.
Once it completes successfully it will return to the Dashboard. You should now see your domain listed.
Please Note: There is a little bug here which we have to fix before proceeding.
You will need to go back into the edit settings by clicking the “hamburger menu” at the end of your domain section and click on “Edit“.
Then click on the “SSL” top menu.
Please ensure that both “Force SSL” and “HTTP/2 Support” are checked. If they have defaulted back then re-select them and click on “Save” again.
If you navigate to your Nextcloud install address using your domain name. You should now see the Installation page.
Please Note: Remember to use HTTPS.
You should also have a valid SSL/TLS certificate which you can confirm by using HTTPS as well as noticing the green padlock icon in the browser.
Step 4 – Installing Nextcloud On Raspberry Pi 4
Now we have completed all the prerequisite it is time to install Nextcloud. You should be at the Nextcloud installation screen within your browser.
Create a “Username” and “Password”.
Under “Storage & database” click the “drop-down icon” to open the hidden menu and select “MySQL MariaDB“
Enter your MariaDB credentials that was set was set in the Nextcloud Stack. Replace “localhost” with “db“.
Important!! Notice: Untick “Install recommended apps” as having this checked can cause the installation to time out.
Click on “Finish setup” to complete the installation.
If all went well you should be greeted with the Nextcloud Dashboard Intro video which you can cross out of.
If you have any installation problems please read our Troubleshooting Installation Problems section below.
Step 5 – Finalizing Cloudflare
Now we have Nextcloud installed we have one final thing to do.
Log back into your Cloudflare account.
Once logged in head to the “DNS” tab. Under DNS management. Go to your CNAME used for your Nextcloud subdomain. Under “Proxy status” click on “DNS only” and change it to “Proxied“. Once set click on “Save“.
What this enables is the ability to mask your ISP provided public facing IP address if a reverse DNS lookup is done on your domain. This protects your privacy by hiding your location, your ISP as well as protecting your network against direct cyber attacks.
Anyone who does a reverse DNS lookup will see Cloudflare’s IP addresses and not yours :).
Troubleshooting Installation problems:
If you run into a timeout message like this:
It may be because you selected to install recommended apps during installation.
As it timed out you may also get a warning that the “The username is already being used” if you try to run the installer a second time.
This happens because, during the first run installation, the username set was added to the database. Even though the installation failed.
What you should do to resolve this is to use a new username and then rerun the installation. Once you are in the Nextcloud dashboard you can remove the unneeded admin account.
If you run into any other problems please let us know by commenting below or on our YouTube video’s comments.
We need your support.
We hope you enjoyed this episode and that it was helpful and you got benefit out of it.
If you did, please consider supporting our channel by Subscribing to our YouTube channel, and liking and sharing our content.
If you have any questions or any requests please ask in the comments below or on YouTube.