Raspberry Pi Print Server With AirPrint (iOS) Compatibility
I was looking for a low cost way for my family to print from their iPhones, iPods and iPads when I realized that this would be a good job for my Raspberry Pi. The web is littered with instructions for this project. I mostly followed Lynsay Shepherd’s tutorial but not exactly. The steps I followed are below.
- First update and upgrade to be sure Raspbian is fully up to date. From the command line type the following and hit enter:
sudo apt-get update
- From the command line type the following and hit enter:
sudo apt-get upgrade
For both of these steps if you’re prompted to continue just say yes. - Next install the packages needed for this project. From the command line type the following and hit enter:
sudo apt-get install avahi-discover cups cups-pdf python-cups
When prompted to continue just say yes. It may take a while for all of these packages to install so be patient. - Add our username to the CUPS server so we’ll be able to administer the server. From the command line type the following and hit enter:
sudo usermod -aG lpadmin pi
This will add the user pi to the list of admins on the CUPS server. If you want to add other users use the same command but replace pi with the username you want to add. - Start the server to be sure it installed correctly. From the command line type the following and hit enter:
sudo /etc/init.d/cups start
If all went well you’ll see the following line and then be back at the command line:
[ ok ] Starting cups (via systemctl): cups.service.
- Edit the CUPS configuration. From the command line type the following and hit enter:
sudo nano /etc/cups/cupsd.conf
- Set up the port that CUPS will listen on. Look for the line that says “Listen localhost:631” and put a # in front of it to comment it out and type the following on the next line:
Port 631
- Set up access control. Arrow down in the config file until you see the following:
# Restrict access to the server...
- After the line that says “Order allow,deny” add a new line and type the following:
Allow @Local
- Repeat step 9 for the following sections:
# Restrict access to the admin pages...
# Restrict access to configuration files... - Hit CTRL-X to exit nano. When prompted to save be sure to say yes and hit enter to confirm the file name.
- Restart the CUPS server to be sure the changes take affect. From the command line type the following and hit enter:
sudo /etc/init.d/cups restart
If all went well you’ll see the following line and then be back at the command line:
[ ok ] Starting cups (via systemctl): cups.service.
The server is now set up. Let’s add a printer. Be sure your printer is attached to the Pi then do the following:
- Launch a web browser and go to https://192.168.1.X:631 (Use the IP address of the Pi and go to port 631.) If prompted that the page is unsafe click the option that will allow you to continue to the page.
- Click Administration.
- Click Add Printer in the Printers section. If prompted for a username and password enter the username and password for the pi account.
- In most cases your printer will be listed in the Local Printer section of the next page. Click the radio button next to it and click the Continue button.
- On the next page be sure to click the Share This Printer box. Feel free to change the Name, Description and/or Location fields (or not). Then click the Continue button.
- On the next page select the appropriate printer driver for your printer. If your printer isn’t listed consult your printer manufacturers website for the Linux driver for your printer. (I had to run ‘
sudo apt-get install hplip
‘ to add my HP printer to the list.) If your driver is in a separate file then click the Choose File button in CUPS, navigate to the driver and click the Open button. - Click the Add Printer button.
The next page is to set default settings for the printer so we won’t worry about that now. Let’s print a test page to see if this all worked.
- Click Printers.
- From the Maintenance menu click Print Test Page.
If all went well your printer will print a test page.
Printing from Mac OSX and iOS should now work with no additional setup. For Windows, however, we need to continue install and configure SAMBA.
- From the command line type the following and hit enter:
sudo apt-get install samba
When prompted to continue just say yes. It may take a while for all of these packages to install so be patient. - Once SAMBA was installed my Windows machines were able to print. If your Windows machines can’t find the printer then edit the SAMBA configuration. From the command line type the following and hit enter:
sudo nano /etc/samba/smb.conf
- Look for the line that says “[printers]” and add the following above it:
printing = cups
printcap name = cups - In the
[printers]
section change the ‘guest ok
‘ setting toyes
. - In the
[print$]
section change ‘path
‘ to/usr/share/cups/drivers
- Hit CTRL-X to exit nano. When prompted to save be sure to say yes and hit enter to confirm the file name.
- Reboot the Pi to be sure all is well.
At this point everything should work. However I had a Windows 10 machine that wasn’t working quite right. After some searching I found the solution outlined here worked for me.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.