Set Up a Print Server with a Raspberry PI

Introduction

This article describes how I set up a print server using a Raspberry Pi (4).

My HP printer does have Wi-Fi, but it always acts up. Besides, I wanted my own server.

Preparing the Raspberry Pi

Installing the Linux Distro

The RPI Imager Tool was very helpful in getting this done:

  • Raspberry Pi, headless image (no desktop)
  • Configure the username
  • Configure the password
  • Used /etc/os-release command to confirm I had installed bullseye

LAN Setup

Set up the RPI LAN like so:

  • At the command line, type: sudo raspi-config
  • Navigate to System Options > Wireless LAN and configure the SSID and Passphrase for Wi-Fi
  • Complete the change by selecting OK and exit the config menu
  • You can use ifgonfig to check that the wireless interface is now connected
  • This would be apparent if the interface for wlan0 has an IP address
  • That's because the RPI uses DHCP to obtain the IP address from your router

Other Setup

This would be a good time to complete some other configurations:

  • At the command line, type: sudo raspi-config
  • Change the locale to something more relevant to you
  • Change the time zone to your local zone
  • Enable SSH if you think you're going to use an application like PuTTY to connect to your RPI
  • Change the hostname - because it's useful to differentiate your RPI from all the others in the house
  • Restart your RPI

Update the RPI

Take the opportunity to update the RPI before continuing.

  • apt-get update
  • apt-get upgrade
  • Restart your RPI

Static IP - NOT

Using static IPs is not good practise.

A better solution is to define the hostname of the RPI on the network router and use the same name in PuTTY to connect to the RPI remotely.

Install the Print Server

Install Cups and configure

Use the following steps:

  • sudo apt install cups
  • sudo usermod -a -G lpadmin username (or whoever the user is)
  • sudo cupsctl --remote-any
  • sudo systemctl restart cups

Setup Samba for Windows Printing

Use the following steps

  • Type sudo apt install samba
  • Make edits to the samba config file by typing: sudo nano /etc/samba/smb.conf
  • Make the following edits:

    # CUPS printing.
    [printers]
    comment = All Printers
    browseable = no
    path = /var/spool/samba
    printable = yes
    guest ok = yes
    read only = yes
    create mask = 0700

    # Windows clients look for this share name as a source of downloadable
    # printer drivers
    [print$]
    comment = Printer Drivers
    path = /var/lib/samba/printers
    browseable = yes
    read only = no
    guest ok = no
  • Save and exit the file and restart samba with sudo systemctl restart smbd
  • Load the drivers for your favourite printer (HP printers) for me: sudo apt-get install hplip,
  • Get the RPI’s IP address with hostname -I
  • Connect the printer to the RPI
  • In a browser on your computer, navigate to the IP address
  • Then navigate to Administration > Add Printer
  • Enter the username and password to the RPI
  • Select the printer and click continue
  • Enable printer sharing and click continue
  • Configure the General settings to set the default options

Configure Windows to the find the RPI Server

On your Windows Computer:

  • Navigate to: Settings > Bluetooth and Devices > Printers & Scanners >
  • Click Add Device and the computer should automatically discover the server.