Follow by Email

Blog Archive

Search This Blog

Setup print server with CUPS and AirPrint on Raspberry Pi

Set up print server with CUPS and AirPrint on Raspberry Pi CUPS (Common Unix Printing System) is a multi-standard open source printing system developed for Unix-like operating systems and supported by Apple for the Mac OS X operating system.
Share it:
Setup print server with CUPS and AirPrint on Raspberry Pi
CUPS-server-AirPrint

CUPS (Common Unix Printing System) is a multi-standard open source printing system developed for Unix-like operating systems and supported by Apple for the Mac OS X operating system.
With CUPS you can operate a printer server (print server) in the network to which one or more USB printers are connected and thus accessible in the network. For a power-saving Raspberry Pi is particularly good. CUPS also takes into account the special features of Windows and Apple networks. For example, Apple's AirPrint is integrated into CUPS and works automatically. This allows iPhones and iPads to print on the network. Windows clients use a Samba client.

Almost all printers are supported by CUPS. For the models that are not supported, there are generic drivers that provide basic functions. Only special functions require a driver from the manufacturer.
Since Hewlett Packard operates its own open source project, HP printers are particularly well supported by CUPS.
Tasks
  • Install and then set up CUPS.
  • Install the printer driver if necessary.
  • Set up the printer in CUPS.
  • Print a file on the command line.
Solution: Installation and setup of CUPS
First, we will update the package lists and upgrade the system.
sudo apt-get update
sudo apt-get upgrade
Then we install CUPS.
sudo apt-get install cups

Depending on the system, the installation process can include several packages over 100 MB. In addition to CUPS, parts of Samba, Avahi, Perl and various libraries will be installed. It may take time to download everything and then install it.

After everything is installed, some changes must be made to the CUPS configuration file.
sudo nano /etc/cups/cupsd.conf

CUPS listens on port 631 by default, but only on the localhost. If you want to access it via the network, you have to release it first.

The line:
Lists localhost: 631

change in:
Port 631

Then the print server should announce all connected printers in the network. For this we add the following line:
BrowseAddress @LOCAL

The value "BrowseAddress" indicates to which hosts printer information is "broadcasted". In this case "@LOCAL" stands for "all" hosts in the locally connected network.

Then search for the following lines and insert in each case an "Allow @Local".
# Restrict access to the server ...
<Location />
Order allow, deny
Allow @LOCAL
</ Location>


# Restrict access to the admin pages ...
<Location / admin>
Order allow, deny
Allow @LOCAL
</ Location>


# Restrict access to configuration files ...
<Location / admin / conf>
AuthType Default
Require user @SYSTEM
Order allow, deny
Allow @LOCAL
</ Location>

"@LOCAL" stands for all networks connected locally to the print server. Exceptions are dial-up connections.

After the changes you have to save and close the file: Ctrl + O, Return, Ctrl + X.

Then we have to add another user to the user group "lpadmin". This can be the default user "pi". You can also create a new user, if you want. But that is not absolutely necessary.
sudo usermod -ag lpadmin pi

Afterwards a restart of the CUPS server is necessary.
sudo service cups restart

This is necessary whenever the configuration file has been changed by CUPS.
Solution: Install printer driver
Depending on the manufacturer and printer model, installing printer drivers is more or less easy. CUPS already comes with printer drivers for popular models. But not for everyone. It still works best with HP printers. Without advertising, HP provides open-source printer drivers for its printers. In other words, an HP printer is usually always up and running with CUPS. Other manufacturers are not so generous here, which is why you have more effort here. Sometimes you can not avoid compiling the driver.

For HP printers, there is a wide selection of printer drivers that are easy to install.
sudo apt-get install hplip

For some Samsung models, there are open printer drivers, which are combined in one package.
sudo apt-get install splix

Downloading and installing the packages may take a little longer. So bring some patience here.

Other manufacturers may require different approaches that vary from model to model. It is recommended to look for the right printer model for the right way.

After installing packages or printer driver, it is recommended to restart CUPS.
sudo service cups restart

Sometimes a reboot of the system is required.

Solution: Set up and manage printers under CUPS
Note: It is easier to set up printers under CUPS if the necessary printer drivers are installed.

Now it's about setting up printers under CUPS. For this you have to connect the printer (s) to the USB of Raspberry Pi now.
Then we configure CUPS. For this purpose, CUPS brings its own web server and can be easily configured via a web interface. For this we need the IP address of Raspberry Pi, which must be entered together with the port number "631" in the browser address line.
https://192.168.1.2:631

It expects the web interface. To set up a printer, proceed as follows:

Under the menu item "Administration" click on the button "Add Printer". Usually you will be asked for username and password. By the user added to the group "lpadmin".

Add a printer (step 1/5)
Then the connected and recognized printers are listed (Local Printers), from which you select the printer you want to set up.
Attention, here all recognized printers are listed, even those, which one already furnished.

Add printer (step 3/5)
Here you can customize the printer name and the description of your own wishes. But you do not have to. In principle, you can leave the default, because this name is usually correct and will be used later on the client systems.
It is only important to set a check mark under "Release". Only then will this printer be made available on the network. If the checkbox is not set, the printer can only be used locally.

Add a printer (step 5/5)
Here you have to select the manufacturer or brand and then as closely as possible the model name.
At this point it is helpful if the printer driver was previously installed. If not, then you can do that now, restart CUPS and re-select the manufacturer. Then the list of model names is updated.

After choosing the right model, we need to set the default settings. Where you usually do not have to change anything. The specifications have already been preselected for the printer model.

After the printer is set up, you can still print a test page. To do this, simply select "Print test page" in the "Maintenance" field. The test print will start automatically.

Solution: Set up a network printer on a client
Basically, the set up printers via AirPrint, for example, for Mac OS, on the iPhone and iPad are available. Under Linux and Windows, you still have to set up the printers as a network printer. The setup dialogs are usually self-explanatory.

Solution: Printing from the console
Basically, you can also send a print job directly from the console. For this one needs the printer name. If you do not know that by heart, then you can look in the printer list.
lpstat -a

There we select the printer name for the following command and specify the path of a text file to be printed out.
lp -d <printer name> </ path / to / textfile>

The status for the current print job, if the document is not yet finished, can be obtained as follows:
lpstat -p

Troubleshooting
Setting up a printer usually succeeds without problems. But sometimes, depending on the manufacturer and printer model, it hooks but then. To solve the problem, we recommend a step-by-step approach, even if the problem is somewhere in between.

First, we'll clarify if the printer (s) will be recognized on the USB. For this we need the "usbutils", which may need to be installed later.
sudo apt-get install usbutils

If the package "usbutils" is installed, then we check if the printer (s) were detected on the USB.
lsusb

This command is sometimes more, sometimes less informative. Typically, the printers are identified by the manufacturer name, perhaps even the model name.
It's a good sign if the printer or printers are recognized on the USB. If not, there are other systemic problems. Maybe a look in "dmesg" helps.
dmesg

The error messages listed there point to problems that are isolated cases. Unfortunately, we can not resolve that here. Maybe the search helps with the error message at the preferred search engine.
Share it:

Raspberry Pi

Post A Comment:

0 comments: