Skip to content

Instantly share code, notes, and snippets.

@solaris9000
Created February 16, 2019 15:28
Show Gist options
  • Save solaris9000/a850056918298bf7aecf5d85ee44394c to your computer and use it in GitHub Desktop.
Save solaris9000/a850056918298bf7aecf5d85ee44394c to your computer and use it in GitHub Desktop.
Setting up print server on Raspberry Pi
----- Setting up PRINT SERVER AKA Airprint on RPI -----
=======================================================
This guide will set up a CUPS based print server on the RPI3 with a USB printer attached.
Some older USB printers do not have wifi or ethernet so if you want to make a printer accessible via your phone or laptop
this is one way to do it.
Pre-Reqs
========
RPI3 for speed with at least 8GB Micro SD card
USB Printer
Installed and updated Raspian
1. apt update && apt dist-upgrade
2. reboot
3. Install the required packages for print server - this contains all the required depenencies, drivers etc in one package
apt install task-print-server
4. Set up the lpadmin group and add pi user to it
usermod -aG lpadmin pi
5. Edit the CUPS conf file
vi /etc/cups/cupsd.conf
Find the blocks of code and insert the highlighted lines:
# Only listen for connections from the local machine.
#Listen localhost:631
Port 631
Listen /var/run/cups/cups.sock
# Show shared printers on the local network.
Browsing On
BrowseLocalProtocols dnssd
# Default authentication type, when authentication is required...
DefaultAuthType Basic
# Web interface setting...
WebInterface Yes
ServerAlias *
# Restrict access to the server...
<Location />
Order allow,deny
Allow 192.168.1.* # Change to your subnet
</Location>
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow 192.168.1.* # Change to your subnet
</Location>
# Restrict access to configuration files...
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow 192.168.1.* # Change to youe subnet
</Location>
6. Restart the services:
/etc/init.d/cups restart; /etc/init.d/avahi-daemon restart
7. Enter the <Local IP:631> in a browser to access the CUPS admin pages and login
8. Goto the Administration Tab and Add Printer
9. Select the discovered printer list on the left - choose the one locally connected to USB
10. Click continue and follow the rest of the options applicable to the chosen printer. Fill in the fields and tick the Sharing box.
11. At the next page choose the correct driver for your printer. In general the driver matched is the one already selected for you. Click Add Printer.
12. The next page lets you select default options for the printer such as page size, colour model etc. If the printer prints colour then ensure the Colour Model is "CMYK" rather than "RGB". Otherwise the colour prints may come out too dark. Once everything is set click Set Default Options.
13.Under Admin Tab, Manage Printers, select the chosen printer and under Maintenance drop down menu, select print test page
14. On any mobile device, print a page of text to test
15. You can also check progress of a print job via the Jobs Tab.
Setup SAMBA for sharing with WINDOWS
====================================
To share the printer you will also need SAMBA for Windows clients. (Ignore this section if you don't use Windows).
1. Install samba usinh:
apt install samba samba-common-bin
2. Edit the /etc/samba/smb.conf file:
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700
# printer drivers
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no
Adding a Printer in Windows
===========================
Once the RPI CUPS print server has been set up its time to add the printer to the client such as Windows.
You can do this via the Add a printer in Win7 or Win10. Use the auto discovery to find the printer. If this doesn't work then manually add the printer path in the format \\<SERVER_NAME>\<PRINTER_NAME>
eg \\RASPBERRYPI\Canon_Printer
Once the printer has been added, do a test print.
You have now completed this print server project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment