Linux Home Server HOWTO
Previous
Home Next

Chapter 15 - System Printing

Version: - cups 1.2.1

Configuring CUPS
Adding CUPS Printers
Installing The Driver File

There have been many Linux printing applications over the years, ranging from sneaker net to full scale network printing systems, all of which continue to get better with developing new technologies. One of the latest Linux printing solutions is the Common UNIX Printing System (CUPS), it supports the Internet Printing Protocol (IPP) and provides a complete platform independent printing solution for most networking environments. The CUPS server is able to be administered remotely using a web browser, which makes it ideal for a 'headless server'.

The initial installation of CUPS only allows access from the host computer and also only supports around twenty different print drivers. This chapter will configure the CUPS daemon so it is accessible for your whole network, it will also give guidance for configuring your own printers and updating their driver files.

Configuring CUPS

The configuration file for CUPS looks and feels very similar to that of Apache, so you may already be familiar with some of the concepts for accept/deny etc.. As with all configuration files we need to back it up before we make any changes. This is particularly important as most of the GUI applications that support CUPS will overwrite the files after you have made changes, so a backup of the original is important.

One of the major CUPS advantages is that it can be completely controlled remotely using a standard web browser, so really all we need to do is get it configured and then access it remotely. However this guide will provide all the steps necessary to configure from the command line (print drivers need to be updated manually).

[bash]# cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.original
[bash]# vi /etc/cups/cupsd.conf

The following basic directives are typical of a standard CUPS configuration, there are many more settings which are available, but most of the default values do not need adjusting. For more details on the full range of directives, type "man cupsd.conf" at the command prompt.

ServerName galaxy.example.com
ServerAdmin [email protected]
AccessLog /var/log/cups/access_log
DataDir /usr/share/cups
DefaultCharset utf-8
DefaultLanguage en
ErrorLog /var/log/cups/error_log
MaxLogSize 10485760
LogLevel info
Printcap /etc/printcap
RequestRoot /var/spool/cups
ServerBin /usr/lib/cups
ServerRoot /etc/cups
User lp
Group sys
Listen 127.0.0.1:631
Listen 192.168.1.1:631

To access the resources remotely via a web browser, we need to specify the access controls (deny/allow) which will be applied to each resource. The "/" (root) resource may be provided to all users without any authentication so they may view which printers are available and the status of the queues.

The "admin" resource has been configured for authentication so that all the administration tasks are only accessible to authorised personnel. It is important to note that no encryption has been established for CUPS in our configuration (it is optional), so if you are administering the system via an untrusted network, be aware that your user details may be captured. This should not be a problem for home networks.

<Location />
      Require valid-user
      Order Deny,Allow
      Deny From All
      Allow From 127.0.0.1
      Allow From 192.168.1.0/24
</Location>

<Location /admin>
      Require group printer-admins
      Order Deny,Allow
      Deny From All
      Allow From 127.0.0.1
      Allow From 192.168.1.0/24
</Location>

 CUPS is a full networking solution and it is capable of browsing the network and discovering other CUPS servers. Depending on the configuration, this allows full administration of all your network printers so they can be centrally managed from the one location. The default for browsing is on, however for a small home network you would probably prefer to turn this feature off.

Browsing Off
BrowseProtocols cups
BrowseOrder Deny,Allow
BrowseAllow from @LOCAL
BrowseAllow from @IF(eth1)

The initial CUPS configuration is now complete. Set the appropriate run levels for your service and then check to make sure they are correct.

[bash]# chkconfig --level 2345 cups on
[bash]# chkconfig --list cups

The service can now be started, be sure to check the system log to see if any errors have occurred.

[bash]# /etc/init.d/cups restart
[bash]# tail /var/log/cups/error_log

The CUPS daemon can now be controlled through a standard web browser if you are connecting from either the localhost, or from the internal network. The service is running on port 631 (default) and can be accessed here: http://localhost:631.


[bash]# groupadd printer-admins
[bash]# usermod -G printer-admins miles


Note !! Printers and their drivers need to be configured before any printing is possible, see below for details.


Adding CUPS Printers

Adding a new printer using the CUPS web interface is very easy, however we are going to configure our printers manually through the configuration files. Firstly we need to make our backup configurations.

[bash]# cp /etc/cups/printers.conf /etc/cups/printers.conf.original
[bash]# vi /etc/cups/printers.conf

All of the details for each of our printers is stored in the "printers.conf" file. The configuration directives needed in the configuration file are very simple, and can be further explained by accessing the man page by typing "man printers.conf" at the command prompt.

You should note that there is a DefaultPrinter and standard Printer configuration (below example), there can only be one DefaultPrinter directive while any additional printers should be defined simply as Printer.

The names for both of these printers (laser and bubblejet) are used in some other configuration areas. So ensure which ever name you choose that they are constant throughout your configuration of that printer.

<DefaultPrinter laser>
      AllowUser miles @laser_printer_group
      Info Laser Printer - Brother HL-1430
      DeviceURI parallel:/dev/lp0
      Location Main Conference Room
      Shared Yes
      State Idle
      Accepting Yes
</Printer>

<Printer bubblejet>
      AllowUser miles
      DenyUser @no_print_group
      Info Bubblejet - HP PhotoSmart-7260
      DeviceURI usb:/dev/usb/lp0
      Location Administration Office
      Shared Yes
      State Idle
      Accepting Yes
</Printer>

The DeviceURI (Uniform Resource Identifiers) specifies the device that is assigned to the printer. Below are some of the possible DeviceURI types and examples. Each printer that is defined in the configuration file must have a DeviceURI specified.

Example DeviceURI Types
#DeviceURI parallel:/dev/plp
#DeviceURI serial:/dev/ttyd1?baud=38400+size=8+parity=none+flow=soft
#DeviceURI scsi:/dev/scsi/sc1d6l0
#DeviceURI socket://hostname:port
#DeviceURI tftp://hostname/path
#DeviceURI ftp://hostname/path
#DeviceURI http://hostname[:port]/path
#DeviceURI ipp://hostname/path
#DeviceURI smb://hostname/printer

In the initial configuration of the CUPS daemon we specified the allow/deny directives for the "/" (root) and "admin" resources. If access to the "/" (root) resource is restricted to only the localhost, then the printer queues will need to be adjusted so that all of the workstations on the internal network can access and print to the queues.

If everyone does have access to the "/" (root) resource, then adding the following details anyway does not matter.

[bash]# vi /etc/cups/cupsd.conf
<Location /printers/laser>
      Order Deny,Allow
      Deny From All
      Allow From 127.0.0.1
      Allow From 192.168.1.0/24
</Location>

<Location /printers/bubblejet>
      Order Deny,Allow
      Deny From All
      Allow From 127.0.0.1
      Allow From 192.168.1.0/24
</Location>

Now that the printers have been configured, the service needs to be restarted so the changes can take effect.

[bash]# /etc/init.d/cups restart
[bash]# tail /var/log/cups/error_log

All of the internal workstations are now able to connect to the printer queues that you have configured. Your print jobs can now be sent straight to "http://www.example.com:631/printers/laser" or "http://192.168.1.1:631/printers/bubblejet", or which ever URL you have configured. Remember you still need to configure your driver file before printing.

Installing The Driver File

When you send a print job to the server it is placed into the desired print queue and then waits to be printed. If the printer understands the format of the file in the queue it will be printed without any problem, however if the format of the file is unknown then the printer will very likely print pages and pages of hieroglyphics; we all hate that !

The printer file we are going to install is a PostScript Printer Description (PPD) file which interprets the file as it gets sent to the print queue, the PPD file details the printers capabilities and ensures that the incoming print job is properly formatted for the printer.

CUPS only has built in support for about 20 generic printers so we need to install extra PPD files for each of the print queues we need to set up. There are two ways to set up the files, an individual PPD for each printer, or by downloading a complete set of PPD files into the CUPS printer list.

Individual Driver Files

To install the individual PPD files we need to head over to LinuxPrinting.org (http://www.linuxprinting.org/printer_list.cgi) and select the printer that we are configuring from the online database. When we have located the correct printer from the database we will be presented with an option to "Download PPD". Download a copy of the PPD file to your local server.

Earlier when we were configuring the print queues in the printers.conf file, we specified two printers which we named laser and bubblejet respectively. To set the correct PPD file with the correct printer, place a copy of the downloaded PPD file into the /etc/cups/ppd directory with the filenames matching the names of the queues, similar to the examples below.

<DefaultPrinter laser> /etc/cups/ppd/laser.ppd
<Printer bubblejet> /etc/cups/ppd/bubblejet.ppd

You should restart the cups service for the PPD files to be loaded.

[bash]# /etc/init.d/cups restart

Complete Driver Set

To configure the complete PPD file set, head over to LinuxPrinting.org (http://www.linuxprinting.org/download/foomatic) and download the latest ("current") foomatic filter tarball.

Using the following commands, extract the tarball file and install the PPD files into CUPS. Once the files have been installed the service should be restarted.

[bash]# wget -O /tmp/foomatic-filters-ppds-current.tar.gz   \
        http://www.linuxprinting.org/download/foomatic/foomatic-filters-ppds-current.tar.gz -U ""
[bash]# tar -xzvf /tmp/foomatic-filters-ppds*.tar.gz -C /tmp
[bash]# cd /tmp/foomatic-filters-ppds*
[bash]# ./install --gzip
[bash]# /etc/init.d/cups restart
[bash]# tail /var/log/cups/error_log
[bash]# cd /
[bash]# rm -Rf /tmp/foomatic-filters-ppds*

The CUPS server may take a few minutes to restart while it imports all the new PPD files, this is normal and the extracted archive is safe to delete once the files have been imported.



Previous
Home Next