2022年11月5日 星期六

[nextcloud, rasp, lxd] Install NextCloud in LXD container on Raspberry Pi

Install NextCloud in LXD container on Raspberry Pi

井民全, Jing, mqjing@gmail.com


This document shows you how to install the NextCloud in a LXD container on Raspberry Pi.



1. Quick

# Raspberry Pi setup

# Setup network

sudo arp-scan -I ens33 --localnet # find your raspberry pi

sudo apt-get -y update --allow-releaseinfo-change


# Setup static IP

sudo vi /etc/dhcpcd.conf

-----------------------------

interface wlan0

static routers=192.168.1.1

static domain_name_servers=8.8.8.8

static ip_address=192.168.1.198/24

-----------------------------

sudo ip link set wlan0 down && sudo ip link set wlan0 up


# install snap

sudo apt install -y snapd

sudo snap install core


sudo reboot


# LXD

# install LXD

sudo snap install lxd --channel=latest/stable

sudo /snap/bin/lxd init

==> Size in GiB of the new loop device (1GiB minimum) [default=23GiB]: 115GiB


sudo usermod -a -G lxd ${USER}

su - ${USER}  # apply the new group membership


# create LXD container for nextcloud

lxc image list images: architecture=armhf os=Ubuntu   # check ubuntu images for Raspberry Pi

lxc launch images:ubuntu/20.04 ubuntu-container

lxc exec ubuntu-container -- passwd ubuntu   # setup the default passwd for normal use

lxc exec ubuntu-container -- apt-get update


# add proxy device

lxc config device add ubuntu-container myport443 proxy listen=tcp:0.0.0.0:443 connect=tcp:127.0.0.1:443


# Nextcloud

# install packages

lxc exec ubuntu-container -- su --login ubuntu   # enter the container

sudo apt install -y snapd   

sudo snap install core

sudo reboot


# install nextcloud

lxc exec ubuntu-container -- su --login ubuntu   # enter the container

sudo snap install nextcloud


verify

snap changes nextcloud

snap info nextcloud

sudo systemctl  | grep nextcloud


# enable https

sudo /snap/bin/nextcloud.enable-https self-signed


# verify

https://192.168.1.198/


2. System Requirement

  1. https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server

3. Detail Procedure

3.1. Raspberry Pi

3.1.1. Step 1:Setup network

sudo arp-scan -I ens33 --localnet # find your raspberry pi

sudo apt-get -y update --allow-releaseinfo-change


# Setup static IP

sudo vi /etc/dhcpcd.conf

-----------------------------

interface wlan0

static routers=192.168.1.1

static domain_name_servers=8.8.8.8

static ip_address=192.168.1.198/24

-----------------------------

sudo ip link set wlan0 down && sudo ip link set wlan0 up



3.1.2. Step 2: Install packages

# install snap

sudo apt install -y snapd

sudo snap install core


sudo reboot


3.2. LXD

3.2.1. Setp 1: Install & Initialized

sudo snap install lxd --channel=latest/stable

sudo /snap/bin/lxd init

==> Size in GiB of the new loop device (1GiB minimum) [default=23GiB]: 115GiB



sudo usermod -a -G lxd ${USER}


su - ${USER}  # apply the new group membership




# if you want to remove the container

# lxc delete ubuntu-container --force




3.2.2. Step 2: Create a container

lxc image list images: architecture=armhf os=Ubuntu   # check ubuntu images for Raspberry Pi

lxc launch images:ubuntu/20.04 ubuntu-container

lxc exec ubuntu-container -- passwd ubuntu   # setup the default passwd for normal use

lxc exec ubuntu-container -- apt-get update

E.g.


3.2.3. Step 3: Add proxy device to container

Redirect https traffic to the container that nextcloud service located.

lxc config device add ubuntu-container myport443 proxy listen=tcp:0.0.0.0:443 connect=tcp:127.0.0.1:443

E.g.


3.3. Install NextCloud in LXD

3.3.1. Step 1: Intall packages

lxc exec ubuntu-container -- su --login ubuntu   # enter the container

sudo apt install -y snapd   

sudo snap install core

sudo reboot


3.3.2. Step 2: Install NextCloud

lxc exec ubuntu-container -- su --login ubuntu   # enter the container

sudo snap install nextcloud


verify

snap changes nextcloud

snap info nextcloud

sudo systemctl  | grep nextcloud


# Other Options


# latest version (26.0.0 dev)

# sudo snap remove nextcloud # remove previous nextcloud

# sudo snap install nextcloud --channel=latest/edge




E.g.


3.3.3. Step 3: Enable https

sudo /snap/bin/nextcloud.enable-https self-signed

E.g.

4. Result

4.1. Browser

https://192.168.1.198/



4.2. iPhone






Windows NextCloud Client


5. Appendix

5.1. Check Temperture

vcgencmd measure_temp

E.g