Do you have a printer which connects to only one computer at a time?
Do you have a spare RaspberryPi?
Then why not put the two together to create a network print server? This allows you to print things from any device on your local network, including iOS devices!
What you need:
- A RaspberryPi running Raspbian
- A USB printer
- A network
- An Ethernet cable or Wi-Fi dongle
- A screen for initial setup
- A keyboard for initial setup
(If any prompts appear asking for a y/n answer, just type y and hit enter)
Log into your RaspberryPi using any account which has root (admin) privileges.
sudo apt-get update
sudo apt-get upgrade
to make sure all your packages are up to date.
sudo apt-get install avahi-daemon avahi-discover libnss-mdns cups cups-pdf gutenprint pycups avahi python2
to install the necessary packages for your print server. Do not worry about any errors that appear.
sudo apt-get install cups
sudo apt-get install python-cups
sudo apt-get install avahi-daemon
Now, either create a new account which you want to use for printing or use your current one. Either way, you need to add them to the group of users which are allowed to print. Use the command:
sudo usermod -aG lpadmin <user name>
replacing <user name> with the user which you want to use for printing.
sudo /etc/init.d/cups start
to make sure CUPS, the main manager of the print server, installed correctly.
If the report “Starting Common Unix Printing System: cupsd” or something similar appears, then CUPS has installed correctly 😀
Then, we need to do the same with Avahi, which allows for AirPrint:
sudo /etc/init.d/avahi-daemon start
If you get “Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon” appears, then Avahi has installed correctly too!
Now, we need to edit CUPS’ configuration file so it works properly:
sudo nano /etc/cups/cupsd.conf
This should open up a basic text editing program.
Now, press the down arrow until you see “Listen localhost:631″.
Place a hash in front of this – this makes the machine not read this part of the file.
Then, create a new line below it and type:
Next, scroll down until you see “<Location />”.
On a new line directly above it, type:
Now, we need to add
below every instance of “Order allow,deny”.
You need to make sure, however, that you do not put it below “Order deny,allow”.
Now, we are finished with this file. Use ctrl-x to exit. When it prompts you if you want to save, press y then enter, then when it asks you what to call it, just press enter without modifying the file name – otherwise CUPS will get confused.
sudo /etc/init.d/cups restart
to restart CUPS with these new changes.
to find your RaspberryPi’s internal IP address.
The string of numbers and full stops after “inet addr:” is your RPi’s IP address. Note this down – they are important in the next step.
Now, open a web browser on another computer in your network and type
replacing <ip address> with the IP address you just found out.
If any warning pages open, just click “Proceed anyway” or your browser’s equivalent.
Navigate to the “Administration” tab and check the checkbox for “Share printers connected to this system” and click “Change settings”.
At the password prompt, just type in the username and password for the user account on the RPi which you are using for printing.
CUPS will reboot and, once is has, click the “Add printer” button. Make sure the printer is connected to your RaspberryPi and turned on.
Then, once it has finished searching for printers, choose the printer you want to use for network printing and press “Continue”.
Give the printer any name and location you want – it will be used to identify the printer on the network. Check the box for “Share this printer” and click “Continue”.
Now, select the name and model of your printer. If it’s not there, you will have to download a PPD file for your printer from http://www.openprinting.org/printers and use the “Choose file” button to add it.
Press “Continue” and you should be given the page for setting up the default configurations for the printer. As long as your printer supports them, give it whatever settings you want. Click “Set Default Options”.
Now, we need to print a test page to make sure we have set up everything ok. Click the “Maintenance” dropdown and click “Print Test Page”. If everything is set up correctly, your printer should print out the page.
Now, just reboot your Pi using either:
sudo shutdown -r now
and log back in.
Now, your printer should be working!