Nextcloud ready Raspberry Pi image

I would like to introduce NextCloudPi, a ready to use Raspbian 8 image with the latest Nextcloud 11.

Features:

  • Raspbian 8 Jessie
  • Nextcloud 11.0.2
  • Apache 2.4.25, with HTTP2 enabled
  • PHP 7.0 (double the speed of PHP5!)
  • MariaDB 10
  • 4.9.13 Linux Kernel ( NEW 03-13-2017 )
  • nextcloudpi-config for easy setup
  • Automatic redirection to HTTPS
  • ACPU PHP cache
  • PHP Zend OPcache enabled with file cache
  • HSTS
  • Cron jobs for Nextcloud
  • Sane configuration defaults
  • Secure

Extras in the FULL version:

Extras are not activated by default. Configure them with sudo nextcloudpi-config

Get it

At this moment, the images do not provide a desktop environment, though it can be added through apt.

Latest release of the base image 03-13-2017

Installation

Follow the classic instructions to copy the image to an SD card.

Replace sdx  to your SD card device.

Windows users can install the image with Etcher as explained in this post.

Usage

Upon first boot, you should do the usual, such as change the default Raspbian password, maybe configure the network connection, enlarge the partition with raspi-config , and enable SSH if you so desire.

You can access your private Nextcloud just typing the IP or URL in the navigation bar of your browser. It will redirect you to the HTTPS site

The admin user is admin, and the default password is ownyourbits. Login to create users, change default password and other configurations.

You can activate and configure the system and any extras with

By default, your data will be kept in your SD card. You will probably want to connect an external USB drive to your Raspberry Pi in order to host your files.

Once your USB drive is properly configured to automount upon boot, set it as your Nextcloud data folder using nextcloudpi-config.

Please, keep in mind that you will be exposing your own private data to the internet and you are the only person responsible for its security. Update your system frequently to get the latest security updates.

You can try NextCloudPi first with qemu-pi.sh  from the last post

Apache logs for Nextcloud are located at /var/www/nextcloud/data/{access,error}.log .

Advanced configuration

In order to access your private cloud from the internet, you should setup a Dynamic DNS and open your ISP router 443 port for HTTPS access.

I use no-ip free plan for my DDNS. It is already included in the FULL version of NextCloudPi.

If you want to avoid the “Untrusted Certificate” warning and make everyone’s life easier, get a Let’s Encrypt signed certificate for your DNS domain.

Again, type sudo nextcloudpi-config  to get everything set up. Follow the dedicated posts on this blog for details on each entry.

Details

Nextcloud is awesome. It allows us to own and control our information without relying on external companies. These companies could change things outside of our control or even shut down the service and we realize only too late that we do not own the software that we use. Nextcloud is certainly a huge tool to protect our privacy and our data.

The big issue though is that it is a web service, so it needs to run on top of an operating system. Setting that up implies long hours of installation, dealing with package versions, configuration and troubleshooting. Many people are not willing or do not have the knowledge to accomplish this task, and I think it is a big reason why it is not that popular outside of the geek niche.

I thought it would help to facilitate already configured images to the public with Nextcloud included, so I automated the process. Let’s go for it!

In the last post we learned how to use qemu-pi.sh  to launch Raspbian on a QEMU virtual machine. We will use this to automatically generate a Raspbian image with Nextcloud 11.0.1 installed.

I recommend to setup qemu-pi.sh  to use a static MAC address so you can always get the same IP through DHCP after each reboot. This is important to automate the process, and for that reason it comes as the default configuration.

Write down the IP that your Raspbian gets from DHCP, and launch

This will get the code from github, and

  • Download latest Raspbian image.
  • Resize the partition.
  • Update the system.
  • Install Apache with HTTP2, PHP7, Mariadb and all that is needed to run Nextcloud.
  • Install Nextcloud.
  • Configure the system.

You can use your own image by setting DOWNLOAD=0 at the top of the script. You can also choose between Raspbian or Raspbian Lite by setting the IMG variable. See the code for details.

At the end of the process you end up with an image that you can write on an SD card and use on your Raspberry Pi.

The good thing about this method is that it is an automated process, so we can easily produce newer versions as Raspbian, Apache and Nextcloud receive updates.

Also note that you can change the following parameters at the top of install-nextcloud.sh

This was tested on Raspberry Pi 2 and Raspberry Pi 3.

Screenshots

The basic configuration and optimizations are already in place, so there are no warnings on the Admin section. We can see that we are using the recommended cron method.

Nextcloud main settings

Also, you can see the default maximum upload size to a sane value of 1G by default. PHP operations time out at one hour. This is important to allow for long uploads and downloads for big files or slow connections.

Other settings

In order to test that you are using HTTP2, look for X-Firefox-Spdy: h2  in the network tab.

HTTP2 test

PHP configuration

PHP Zend OPCache Settings
PHP ACPU settings

If you have ever manually configured a Nextcloud instance, the auto-configuration parameters by default are equivalent to this

Nextcloud default configuration
Code

github

References

https://docs.nextcloud.com/server/11/admin_manual/contents.html

https://www.raspberrypi.org/forums/viewtopic.php?f=36&t=160874

Raspbian on QEMU with network access

 

Humbly sharing things that I find useful [ github | gist ]