Science and technology

Host your personal cloud with Raspberry Pi NAS

In the primary two elements of this sequence, we mentioned the hardware and software fundamentals for constructing network-attached storage (NAS) on a Raspberry Pi. We additionally put a correct backup strategy in place to safe the info on the NAS. In this third half, we’ll speak about a handy solution to retailer, entry, and share your information with Nextcloud.

Prerequisites

To use Nextcloud conveniently, it’s a must to meet just a few conditions. First, you must have a website you should utilize for the Nextcloud occasion. For the sake of simplicity on this how-to, we’ll use nextcloud.pi-nas.com. This area must be directed to your Raspberry Pi. If you need to run it on your property community, you in all probability must arrange dynamic DNS for this area and allow port forwarding of ports 80 and 443 (in the event you go for an SSL setup, which is very really helpful; in any other case port 80 must be enough) out of your router to the Raspberry Pi.

You can automate dynamic DNS updates from the Raspberry Pi utilizing ddclient.

Install Nextcloud

To run Nextcloud in your Raspberry Pi (utilizing the setup described within the first part of this sequence), set up the next packages as dependencies to Nextcloud utilizing apt.

sudo apt set up unzip wget php apache2 mysql-server php-zip php-mysql php-dom php-mbstring php-gd php-curl

The subsequent step is to obtain Nextcloud. Get the latest release’s URL and replica it to obtain through wget on the Raspberry Pi. In the primary article on this sequence, we connected two disk drives to the Raspberry Pi, one for present information and one for backups. Install Nextcloud on the info drive to verify information is backed up routinely each evening.

sudo mkdir -p /nas/information/nextcloud
sudo chown pi /nas/information/nextcloud
cd /nas/information/
wget https://obtain.nextcloud.com/server/releases/nextcloud-14.zero.zero.zip -O /nas/information/nextcloud.zip
unzip nextcloud.zip
sudo ln -s /nas/information/nextcloud /var/www/nextcloud
sudo chown -R www-data:www-data /nas/information/nextcloud

When I wrote this, the newest launch (as you see within the code above) was 14. Nextcloud is below heavy growth, so it’s possible you’ll discover a newer model when putting in your copy of Nextcloud onto your Raspberry Pi.

Database setup

When we put in Nextcloud above, we additionally put in MySQL as a dependency to make use of it for all of the metadata Nextcloud generates (for instance, the customers you create to entry Nextcloud). If you’d moderately use a Postgres database, you will want to regulate among the modules put in above.

To entry the MySQL database as root, begin the MySQL consumer as root:

sudo mysql

This will open a SQL immediate the place you’ll be able to insert the next instructions—substituting the placeholder with the password you need to use for the database connection—to create a database for Nextcloud.

CREATE USER nextcloud IDENTIFIED BY '<insert-password-here>';
CREATE DATABASE nextcloud;
GRANT ALL ON nextcloud.* TO nextcloud;

You can exit the SQL immediate by urgent Ctrl+D or coming into stop.

Web server configuration

Nextcloud may be configured to run utilizing Nginx or different net servers, however for this how-to, I made a decision to go along with the Apache net server on my Raspberry Pi NAS. (Feel free to check out one other different and let me know in the event you assume it performs higher.)

To set it up, configure a digital host for the area you created to your Nextcloud occasion nextcloud.pi-nas.com. To create a digital host, create the file /and so forth/apache2/sites-available/001-nextcloud.conf with content material just like the next. Make positive to regulate the ServerName to your area and paths, in the event you did not use those urged earlier on this sequence.

DigitalHost *:80>
ServerName nextcloud.pi-nas.com
ServerAdmin [email protected]
DocumentRoot /var/www/nextcloud/

<Directory /var/www/nextcloud/>
AllowOverride None
</Directory>
</DigitalHost>

To allow this digital host, run the next two instructions.

a2ensite 001-nextcloud
sudo systemctl reload apache2

With this configuration, you must now be capable of attain the net server along with your area through the net browser. To safe your information, I like to recommend utilizing HTTPS as a substitute of HTTP to entry Nextcloud. An easy (and free) approach is to acquire a Let’s Encrypt certificates with Certbot and have a cron job routinely refresh it. That approach you do not have to fiddle with self-signed or expiring certificates. Follow Certbot’s easy how-to instructions to install it on your Raspberry Pi. During Certbot configuration, you’ll be able to even determine to routinely ahead HTTP to HTTPS, so guests to http://nextcloud.pi-nas.com might be redirected to https://nextcloud.pi-nas.com. Please observe, in case your Raspberry Pi is operating behind your property router, it’s essential to have port forwarding enabled for ports 443 and 80 to acquire Let’s Encrypt certificates.

Configure Nextcloud

The last step is to go to your recent Nextcloud occasion in an online browser to complete the configuration. To achieve this, open your area in a browser and insert the database particulars from above. You may also arrange your first Nextcloud consumer right here, the one you should utilize for admin duties. By default, the info listing must be contained in the Nextcloud folder, so that you needn’t change something for the backup mechanisms from the second part of this series to select up the info saved by customers in Nextcloud.

Afterward, you’ll be directed to your Nextcloud and might log in with the admin consumer you created beforehand. To see an inventory of really helpful steps to make sure a performant and safe Nextcloud set up, go to the Basic Settings tab within the Settings web page (in our instance: https://nextcloud.pi-nas.com/settings/admin) and see the Security & Setup Warnings part.

Congratulations! You’ve arrange your personal Nextcloud powered by a Raspberry Pi. Go forward and download a Nextcloud client from the Nextcloud web page to sync information along with your consumer gadgets and entry it offline. Mobile purchasers even present options like on the spot add of images you are taking, so that they’ll routinely sync to your desktop PC with out questioning get them there.

Most Popular

To Top