JustToThePoint English Website Version
JustToThePoint en español
JustToThePoint in Thai

Set up a Raspberry Pi Server II

Raspberry Pi Server

  1. Prepare the hard drive (sdb1, let’s suppose a second hard drive). We can find its UUID (UUID stands for Universally Unique Identifier) by typing: ls -la /dev/disk/by-uuid […] root root 10 Mar 28 04:23 ece31d22-201d-4421-b540-4337b029d72f -> ../../sdb1. Let’s edit fstab: sudo vi /etc/fstab and add a line like this:
    UUID=ece31d22-201d-4421-b540-4337b029d72f (device or filesystem to be mounted) /media/mydisk (mount point for the filesystem) ext4 (it describes the type of the filesystem) nofail,auto (options: nofail, do not report errors for this device if it does not exist; auto, the filesystem can be mounted automatically) 0 (dump option. It is seldom used so if you are in doubt, just use 0) 0 (disable checking the file system at boot).
  2. sudo mount -a: it causes all filesystems mentioned in fstab to be mounted as indicated.
  3. Install Samba: sudo apt install samba. Arch: sudo pacman samba
  4. Configure Samba: sudo vi /etc/samba/smb.conf
        [pi] # Each section in the configuration file describes a shared resource
          path = /media/mydisk/samba # This is the shared resource's path     
          comment = My Samba Share # Comment string to be associate with the new shared resource     
          browseable = yes # The resource is seen in the list of available shares in a net view and in the browse list     
          read only = no # read only = no, and writable = yes allow all users to access and write     
          create mask = 0700     
          directory mask = 0700     
          writable = yes     
          valid users = nmaximo7 # It restricts access to specific users8. Create a user group: _sudo groupadd -r sambausers_
  5. Add my user (nmaximo7) to this group (sudo usermod -aG sambausers nmaximo7) and add a password to my user to use this service: sudo smbpasswd -a nmaximo7. Note: Samba uses a password separate from that of the Linux user accounts.
  6. Change the ownership and permissions of the samba directory: sudo chown -R root:sambausers /media/mydisk/samba, sudo chmod 1770 /media/mydisk/samba
  7. Restart the samba service (Pi): sudo service smbd restart. Enabling and starting services (Arch): sudo systemctl enable ‐‐now smb, sudo systemctl enable ‐‐now nmb
  8. Configure firewall (Arch): firewall-cmd ‐‐permanent ‐‐add-service={samba,samba-client,samba-dc} ‐‐zone=home
  9. On the client computer, access the shared folder from your file manager. If you are using Windows, open File Explorer and click Network on the left pane. If you are using GNU/Linux, open Nautilus, Other Locations, connect to server, and type smb://IP’s Samba Server.
  1. Let’s install Docker on Raspberry Pi. First, we will update and upgrade the system: sudo apt-get update && sudo apt-get upgrade
  2. Download (curl) and execute the installation script: curl -sSL https://get.docker.com​ | sh
  3. Add a non-root user (pi) to the docker group: sudo usermod -aG docker pi
  4. Check Docker version (docker version) and test it by running the Hello World container: docker run hello-world.
  5. Docker compose is a tool for running multi-container applications on Docker. Let’s install it. First, we need to install some dependencies: sudo apt-get install -y libffi-dev libssl-dev. sudo apt-get install -y python3 python3-pip. sudo apt-get remove python-configparser. Next, we install docker compose: sudo pip3 -v install docker-compose.
  6. A few more commands. List all running Docker containers: sudo docker ps. List all containers, both running and stopped: sudo docker ps –a. Delete containers: docker rm IdContainer. Delete all “exited” containers: docker container prune. Start a stopped docker container: docker start IdContainer. Start a container in interactive mode: docker run -it ubuntu.
  1. Let’s install it with Docker. First, we pull an image of Nextcloud: docker pull nextcloud.
  2. Run your image as a container and start Nextcloud: docker run ‐‐name nextcloud -d -p 8080:80 nextcloud. Container images are configured using parameters passed at runtime: -p 8080:80 would expose port 80 from inside the container to be accessible from the host’s IP on port 8080 outside the container. -d is the detached mode: run the container in the background and print the new container ID. ‐‐name nextcloud: Assign the name “nextcloud” to the container.
  3. Using a browser navigate to https://ip-address:8080 (Remember: -p 8080:80) and start the Nextcloud setup screen. It uses SQLite by default. SQLite is an open-source, self-contained database engine designed to be embedded into an application, but it is not recommended, so we are going to use PostgreSQL instead of SQLite.
  4. We need to stop our running container: docker stop nextcloud (Remember: ‐‐name nextcloud). Next, we remove the container: docker rm nextcloud.
  5. Let’s pull an image of PostgreSQL (a free and open-source relational database management system): docker pull postgres.
  6. Next, we need to create a Docker network. It allows containers connected to the same bridge network to communicate, while providing isolation from containers which are not connected to that bridge network. Create a user-defined bridge network: docker network create ‐‐driver bridge nextcloud-net. ‐‐driver bridge is the default network driver. Bridge networks are usually used when your applications run in standalone containers that need to communicate. nextcloud-net would be the docker network’s name.
  7. Start the PostgreSQL container in the docker network: docker run ‐‐name postgres -e POSTGRES_PASSWORD=mysecretpassword ‐‐network nextcloud-net -d postgres (default user: postgres, POSTGRES_PASSWORD sets the superuser password for PostgreSQL: mysecretpassword).
  8. Start the Nextcloud container in the docker network: docker run ‐‐name nextcloud -d -p 8080:80 -v /home/pi/nextcloud:/var/www/html ‐‐network nextcloud-net nextcloud. -v /home/pi/nextcloud:/var/www/html: /var/www/html is the folder where all Nextcloud data lives, /home/pi/nextcloud is our “mounted” host directory in the docker container.
  9. Using a browser navigate to https://ip-address:8080. Create an admin Account. Configure the database: Switch the database type to PostgreSQl and type the credentials: Database user (postgres), Database password (mysecretpassword), Database name (postgres), change localhost to postgres (the name of the container).
  10. Install client apps to sync your files (Desktop, Android or iOS). Download, install, and login (Server address: https//dirIPRaspberryPi). Install some apps so you can add all sorts of functionality to your Nextcloud server: OnlyOffice (real-time document editing and collaborative capabilities), News (a RSS/Atom feed reader), Passwords (a Password Manager), Music, AppOrder, etc.
Bitcoin donation

JustToThePoint Copyright © 2011 - 2022 PhD. Máximo Núñez Alarcón, Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.