Raspberry Pi as server

Setup & config options

Apache 2.4+ LAMP server

»Windward« server

The game & not the islands
 Setup & config options

Some off-topics
Free weather app. Weather widget

Lat. 52.27, Long. 8.01

 

Meteorological service

Front desk clerk

🚫  No ads & tracking

Tag cloud
QRC bookmark

QR quick response code




Github VSCO Vimeo | Madeira | Madeirense Watch on Youtube

The prologue


Most of the articles, descriptions and instructions written here are applicable to the most common Debian-based Linux derivatives. Depending on the respective operating system, there may be minor or major discrepancies.
This website is for educational purposes only. Please do not deploy anything in manufacturing plants.
No warranty or compensation is given for loss of data or hardware.

It should be also mentioned that this modest web server is hosted on a Raspberry Pi type 4B at home.


The Raspberry Pi mini-computer board as multi-purpose server deployed
A competent allrounder for domestic purposes and micro-enterprises


Raspberry Pi : Apache as multiple web server. Print server, scan server, backup and NAS server. Raspberry Pi : Apache as multiple web server. Print server, scan server, backup and NAS Server.

Raspberry Pi is a series of small single-board computers (SBCs) developed in the United Kingdom by the Raspberry Pi Foundation in association with Broadcom. The mini-computer with its armv7l processor has quickly become the favourite of hobbyists. Projects can be started with suitable Linux distributions. Even an aged RasPi e.g. the models 2B and 2B+ can definitely serve to simple tasks quite well.


Caution ! Proprietary and untested third-party software sources (Linuxes) can threaten the system.


Prologue


This description is valid for any Raspberry Pi with Debian, Raspbian operating system. It is also possible to use an old and small netbook or similar. I am mainly concerned in this manual / description about the use of computers with low power consumption in residential home networks and micro-enterprises.


If the main scan device is not yet connected to the local network.


SANE | Get the scanner device from the All-In-One printer working
... on your local network server


Raspberry Pi network print serverRaspberry Pi ←→ Ethernet ←→ Hub / Modem / Router
Raspberry Pi ←→ USB ←→ All-In-One printer (with scanner)


Raspberry Pi operates as »headless« server : no monitor, no mouse device and no keyboard plugged.


SANE project | Prologue


The SANE-project : Scanner Access Now Easy


Scanners are available in many versions. To use the basic functions of a scanner, such as resolution, black and white / grayscale / color scans or special keys, a device driver is required. Debian, Linux and Ubuntu in general uses its own open interface for scanners, which is independent from the manufacturers: the SANE interface. This interface was developed as a standard not only for flatbed scanners, but also for All-In-One printers, hand scanners, video and still cameras or frame grabbers.


Server | Preparatory work


Step-By-Step : connect your Raspberry Pi via LAN-cable (ethernet) to your local Hub, modem or router. Connect your Raspberry Pi via USB-cable to your printer. Switch on the printer then switch on (boot) the Raspberry Pi. Login via the terminal program.


pi@NetworkPrinter:~ $ sudo su
root@NetworkPrinter:# apt update && apt upgrade

Server | Rpi-update


Not needed, just in case. »rpi-update« is a command line application that will update your Raspberry Pi OS kernel and VideoCore firmware to the latest pre-release versions. WARNING: Pre-release versions of software are not guaranteed to work. Execute the command only as a last resort and be sure to make a backup of your important data.


root@NetworkPrinter:# rpi-update

Client | Preparatory work


Login via terminal the program.


client:~ $ sudo su
root@client:# apt update && apt upgrade


SANE | Server (Raspberry Pi) setup and configuration


Merely install the SANE interface and not more.


root@NetworkPrinter:# apt install sane --no-install-recommends


SANE comes with useful tools for checking the configuration.
Find out if it can find the scan device in your All-In-One printer.
For our case we have it to deal with my antique HP Deskjet All-In-One printer F4180.


root@NetworkPrinter:# sane-find-scanner


    # sane-find-scanner will now attempt to detect your scanner. If the
    # result is different from what you expected, first make sure your
    # scanner is powered up and properly connected to your computer.

    # No SCSI scanners found. If you expected something different, make sure that
    # you have loaded a kernel SCSI driver for your SCSI adapter.



    found USB scanner (vendor=0x03f0 [HP], product=0x7e04 [Deskjet F4100 series])
                                                                at libusb:001:005
    found USB scanner (vendor=0x0424, product=0xec00) 
                                    at libusb:001:003


    # Your USB scanner was (probably) detected. It may or may not be supported by
    # SANE. Try scanimage -L and read the backend's manpage.

    # Not checking for parallel port scanners.

    # Most Scanners connected to the parallel port or other proprietary ports
    # can't be detected by this program.
	

root@NetworkPrinter:# scanimage -L


    device `hpaio:/usb/Deskjet_F4100_series?serial=CN7CQ6V11X04TJ' is a 
                        Hewlett-Packard Deskjet_F4100_series all-in-one
	

Try scanning something to confirm the functionality. Be patient. Your little Raspberry Pi needs a while.
Put a printed A4 sample sheet inside the scanner and use the command.


root@NetworkPrinter:# scanimage > ~/test-scanner.pnm


Details about the test file scanned. Also you can open the *.prm file with a program like GIMP.


root@NetworkPrinter:# file ~/test-scanner.pnm


    /root/test-scanner.pnm: Netpbm image data, size = 638 x 877, rawbits, pixmap
	

Scanner works now locally. Now set up the sane daemon.
Alter the configuration file /etc/default/saned and to turn the sane daemon/server on


root@NetworkPrinter:# nano /etc/default/saned


    # Defaults for the saned initscript, from sane-utils

    # Set to the user saned should run as
    RUN_AS_USER=saned
    RUN=yes
	

Alter the file /etc/sane.d/saned.conf and tell the server to accept connections from all IP addresses in the range 192.168.1.1 to 192.168.1.255 (IP ranges varies, use hostname -I to identify).
Uncomment the line : #data_portrange = 10000 - 10100.


root@NetworkPrinter:# nano /etc/sane.d/saned.conf


    ...
    ## Daemon options
    # Port range for the data connection. Choose a range inside [1024 - 65535].
    # Avoid specifying too large a range, for performance reasons.
    #
    # ONLY use this if your saned server is sitting behind a firewall. If your
    # firewall is a Linux machine, we strongly recommend using the
    # Netfilter nf_conntrack_sane connection tracking module instead.
    #
    data_portrange = 10000 - 10100
    ...
    ...
    #scan-client.somedomain.firm
    #192.168.0.1
    #192.168.0.1/29
    #[2001:db8:185e::42:12]
    #[2001:db8:185e::42:12]/64

    192.168.1.0/24
    ...
	

The SANE daemon has to access the scanner without »root« permissions.

"Found USB scanner" ... "at libusb:001:005" tells, scanner is located at /dev/bus/usb/001/005.


root@NetworkPrinter:# ls -l /dev/bus/usb/001


    total 0
    crw-rw-r--  1 root root 189, 0 Oct 11 06:14 001
    crw-rw-r--  1 root root 189, 1 Oct 11 01:37 002
    crw-rw-r--  1 root root 189, 2 Oct 11 01:37 003
    crw-rw-r--  1 root root 189, 3 Oct 11 06:14 004
    crw-rw-r--+ 1 root lp   189, 4 Oct 11 06:14 005
	

The scanner is owned by »root« within the group »lp« - »linux printing«.
Add the SANE daemon to the group »lp« for the essential permissions.


root@NetworkPrinter:# adduser saned lp


    Adding user `saned' to group `lp' ...
    Adding user saned to group lp
    Done.
	

Restart SANE daemon to overtake the changes.


root@NetworkPrinter:# systemctl start saned.socket


root@NetworkPrinter:# systemctl enable saned.socket


root@NetworkPrinter:# systemctl status saned.socket


     saned.socket - saned incoming socket
       Loaded: loaded (/lib/systemd/system/saned.socket; enabled; 
                                                     vendor preset: enabled)
       Active: active (listening) since Sun 2020-10-11 21:55:06 CEST; 5min ago
       Listen: [::]:6566 (Stream)
     Accepted: 0; Connected: 0;
        Tasks: 0 (limit: 995)
       CGroup: /system.slice/saned.socket
 
    Oct 11 21:55:06 NetworkPrinter systemd[1]: Listening on saned incoming socket.
	

Perform a »nmap« port scan. Use either hostname or the IP-address of your Raspberry Pi.


root@NetworkPrinter:# apt install nmap


root@NetworkPrinter:# nmap networkprinter


    Starting Nmap 7.70 ( https://nmap.org ) at 2020-10-11 22:17 CEST
    Nmap scan report for NetworkPrinter (192.168.1.27)
    Host is up (0.00044s latency).
    rDNS record for 192.168.1.27: Pi-PrintServer.fritz.box
    Not shown: 994 closed ports
    PORT     STATE SERVICE
    22/tcp   open  ssh
    ...
    ...
    631/tcp  open  ipp
    6566/tcp open  sane-port

    Nmap done: 1 IP address (1 host up) scanned in 9.17 seconds
	

Now everything is fine. The Raspberry Pi has services linked to port 22 for SSH, port 631 for printing via CUPS and port 6566 for scanning via SANE.


It's coffeetime now !


Coffee break


SANE | Client (laptop, notebook, PC workstation) setup and configuration


XSane is an open source and freely distributed graphical application implemented in GTK+ and designed from the offset to act as a GUI (Graphical User Interface) for the SANE (Scanner Access Now Easy) image scanning command-line program.


Skanlite is a simple image scanning application to scan and save images. Skanlite is based on libksane, an interface for SANE library to control image scanners.


Simple Scan is a PDF document scanner application. You can scan documents, photos, receipts, reports, or just about anything. The scan will be saved to the device in image or PDF format.


root@client:# apt install xsane skanlite simple-scan


Simple Scan is my favourite because it is so simple.


Tell your client computer where to search for the SANE services.
Uncomment one line in /etc/sane.d/net.conf and enter the IP-address of your Raspberry Pi.


root@client:# nano /etc/sane.d/net.conf


    # This is the net backend config file.

    ## net backend options
    # Timeout for the initial connection to saned. This will prevent the backend
    # from blocking for several minutes trying to connect to an unresponsive
    # saned host (network outage, host down, ...). Value in seconds.
    connect_timeout = 60

    ## saned hosts
    # Each line names a host to attach to.
    # If you list "localhost" then your backends can be accessed either
    # directly or through the net backend.  Going through the net backend
    # may be necessary to access devices that need special privileges.
    # localhost
    192.168.1.27
	

Client and server | Complementary work


To be on the safe side reboot client and server. Clientside close all open applications.


root@client:# shutdown -r now


root@NetworkPrinter:# shutdown -r now


Work done. Scan a test document after reboot.


11-Oct 2020


dosboot.org 2024 | Design and layout handmade in Northwest Europe