
In the first part, https://www.oprocs.com/raspberry-pi-home-server-part-1/ we have installed Operating System, Firmware Update if needed and static ip address is assigned. Now, the process will continue with installation of Docker and then portainer installation and shellinabox will continue. Finally, nextcloud installation will be done.
Chapter 3 : PACKAGES INSTALLATION
The following update and upgrade processes are highly recommended due to official security patches are applied to the server.
$ sudo apt update
$ sudo apt upgrade
3.1 Docker

The developer starts with a project and choose the needs for. Many softwares gets update and sometimes they have deprecate their own codes. So, the developers in a project may use different version of a specific code in open-source community and this may conflict, or bugs. That specific version need to be installed but the programmer also need that database with different version to code in different project or need to check that project or need to use it.
What does docker do ? It containerizes. The specific versions is coded in the beginning and in the installation process this specific versions are installed with no conflict or bugs. The following code will install the docker on the system.
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh

The following command adds a non-root user to use the docker to have administrator priviliges. pi is the default user and default user is defined as follow.
$ sudo usermod -aG docker [user_name]
If you are sticked with default username “pi”
$ sudo usermod -aG docker pi
Close the session or reboot the system. Now the user has the administrator privileges. Docker version and info is also can be reached by the following commands:

$ docker version
$ docker info
3.2 Portainer

Docker is installed but the terminal is needed to be used for the managing container. We can use docker commands in terminal but Portainer web-gui makes lots of things easier. Portainer has a web-gui to manage container.

$ sudo docker pull portainer/portainer-ce:latest
$ sudo docker run -d -p 9000:9000 -p 9443:9443 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
Now, we can reach the portainer with using browser with http://serverip:9000 Set the password and username is admin. You will create your own password of portainer at this phase.


If you noticed that there is an App templates which is quite useful to install applications which are designed by people. You can change the default template with github/novaspirit -thanks to all contributors-. This template do most of the things which is called here automatically but still you need to arrange the things. Just doesn’t manually using stack. Anyway… How to add the new one ? Please go to the link and use the right version for you. It differs between x86 with x64. The x86 is given below. Link: https://github.com/novaspirit/pi-hosted
https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/template/portainer-v2-arm32.json

Additional Package : Shell in a Box
We need to use terminal or command window for ssh connection. The same procedure can be done by using browser screen. If you want to use a browser screen for using raspberry pi terminal, we need to install shellinabox.
$ sudo apt install shellinabox
After the installation, choose your favourite browser and type your raspberry pi’s local address with port 4200.
http://192.168.X.X:4200

3.3 Nextcloud
Nextcloud is a cloud based file storage system for the users who can create self hosted server and set it up. It is free, powerful and have many many abilities. The admin also can create users and determine the storage size for the other users. Primary quest of this paper is focusing on setting the nextcloud and some useful tips.
Create a stack named nextcloud and paste the code.
Btw, You don’t have to install nextcloud by using stack. Just go app template, and install nextcloud.
---
version: "2"
services:
nextcloud:
image: linuxserver/nextcloud:latest
container_name: nextcloud
environment:
- PUID =1000
- PGID =1000
- TZ=Europe/Istanbul
volumes:
- /portainer/Files/AppData/Config/Nextcloud/Config :/config
ports:
- 8443:443
restart: unless-stopped
depends_on:
- nextcloud_db
nextcloud_db:
image: linuxserver/mariadb:latest
container_name: nextcloud_db
environment:
- PUID =1000
- PGID =1000
- MYSQL_ROOT_PASSWORD= ChangeThisRootPassword
- TZ=Europe/Istanbul
- MYSQL_DATABASE=nextcloud_db
- MYSQL_USER=nextcloud
- MYSQL_PASSWORD= ChangeThisMysqlPassword
volumes:
- /portainer/Files/AppData/Config/Nextcloud/DB :/config
restart: unless-stopped
Change the parameters given below and set them for your configuration.
- 8443:443
- TZ=Europe/Istanbul
- MYSQL_ROOT_PASSWORD= ChangeThisRootPassword
- MYSQL_PASSWORD= ChangeThisMysqlPassword
Database user is: nextcloud
Database is : nextcloud_db
Set the nextcloud with these parameters. Connect to your ip. My raspberry pi ip is 192.168.1.10.
https://192.168.1.10:8443
Accept the risks and continue. Click Storage & Database. Then, Continue with choosing MySQL/Mariadb. Configure your database with your settings. AUserName is just a root user created in this phase.


If you see the following installation of recommended apps. You are at the right path. It is done.

For the cron job You should do the following commands. Don’t forget: the cron.php file location need to be updated if you install nextcloud to a different path.
$ crontab -u www-data -e
*/5 * * * * php -f /portainer/Files/AppData/Config/Nextcloud/Config/www/nextcloud/cron.php
$ crontab -u www-data -l
App Template is quite usefull to install: Homer, Airsonic-advanced, File Browser etc. I will use them in the next part.