From Fedora Project Wiki
fp-wiki>ImportUser
(Imported from MoinMoin)
 
(→‎Configuring CUPS: add some of the missing markup)
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:


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).
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).
 
<pre>
[bash] # cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.original
[bash] # cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.original
[bash] # vi /etc/cups/cupsd.conf
[bash] # vi /etc/cups/cupsd.conf
 
</pre>
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.
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.


<pre>
ServerName galaxy.example.com
ServerName galaxy.example.com
ServerAdmin admin@example.com
ServerAdmin admin@example.com
Line 30: Line 31:
Listen 127.0.0.1:631
Listen 127.0.0.1:631
Listen 192.168.1.1:631
Listen 192.168.1.1:631
</pre>


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.
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.
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.
 
<pre>
<Location />
<Location />
Require valid-user
Require valid-user
Line 50: Line 52:
Allow From 192.168.1.0/24
Allow From 192.168.1.0/24
</Location>
</Location>
 
</pre>
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.
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.
 
<pre>
Browsing Off
Browsing Off
BrowseProtocols cups
BrowseProtocols cups
Line 58: Line 60:
BrowseAllow from @LOCAL
BrowseAllow from @LOCAL
BrowseAllow from @IF(eth1)
BrowseAllow from @IF(eth1)
 
</pre>
The initial CUPS configuration is now complete. Set the appropriate run levels for your service and then check to make sure they are correct.
The initial CUPS configuration is now complete. Set the appropriate run levels for your service and then check to make sure they are correct.
 
<pre>
[bash] # chkconfig --level 2345 cups on
[bash] # chkconfig --level 2345 cups on
[bash] # chkconfig --list cups
[bash] # chkconfig --list cups
 
</pre>
The service can now be started, be sure to check the system log to see if any errors have occurred.
The service can now be started, be sure to check the system log to see if any errors have occurred.
 
<pre>
[bash] # /etc/init.d/cups restart
[bash] # /etc/init.d/cups restart
[bash] # tail /var/log/cups/error_log
[bash] # tail /var/log/cups/error_log
 
</pre>
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.
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.


 
<pre>
[bash] # groupadd printer-admins
[bash] # groupadd printer-admins
[bash] # usermod -G printer-admins miles
[bash] # usermod -G printer-admins miles
</pre>


{{admon/note|Note|Printers and their drivers need to be configured before any printing is possible, see below for details.}}


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


 
== Adding CUPS Printers ==
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.
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.
 
<pre>
[bash] # cp /etc/cups/printers.conf /etc/cups/printers.conf.original
[bash] # cp /etc/cups/printers.conf /etc/cups/printers.conf.original
[bash] # vi /etc/cups/printers.conf
[bash] # vi /etc/cups/printers.conf
 
</pre>
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.
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.


Line 90: Line 92:


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.
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.
 
<pre>
<DefaultPrinter laser>
<DefaultPrinter laser>
AllowUser miles @laser_printer_group
AllowUser miles @laser_printer_group
Line 111: Line 113:
Accepting Yes
Accepting Yes
</Printer>
</Printer>
 
</pre>
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.
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
== Example DeviceURI Types ==


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.
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.
If everyone does have access to the "/" (root) resource, then adding the following details anyway does not matter.
 
<pre>
[bash] # vi /etc/cups/cupsd.conf
[bash] # vi /etc/cups/cupsd.conf
<Location /printers/laser>
<Location /printers/laser>
Line 134: Line 136:
Allow From 192.168.1.0/24
Allow From 192.168.1.0/24
</Location>
</Location>
 
</pre>
Now that the printers have been configured, the service needs to be restarted so the changes can take effect.
Now that the printers have been configured, the service needs to be restarted so the changes can take effect.
 
<pre>
[bash] # /etc/init.d/cups restart
[bash] # /etc/init.d/cups restart
[bash] # tail /var/log/cups/error_log
[bash] # tail /var/log/cups/error_log
 
</pre>
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.
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
== 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 !
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 !


Line 149: Line 151:
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.
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
== 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.
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.
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.
 
<pre>
<DefaultPrinter laser> /etc/cups/ppd/laser.ppd
<DefaultPrinter laser> /etc/cups/ppd/laser.ppd
<Printer bubblejet> /etc/cups/ppd/bubblejet.ppd
<Printer bubblejet> /etc/cups/ppd/bubblejet.ppd
 
</pre>
You should restart the cups service for the PPD files to be loaded.
You should restart the cups service for the PPD files to be loaded.
 
<pre>
[bash] # /etc/init.d/cups restart
[bash] # /etc/init.d/cups restart
 
</pre>
Complete Driver Set
== 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.
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.
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.
 
<pre>
[bash] # wget -O /tmp/foomatic-filters-ppds-current.tar.gz  \
[bash] # wget -O /tmp/foomatic-filters-ppds-current.tar.gz  \
http://www.linuxprinting.org/download/foomatic/foomatic-filters-ppds-current.tar.gz -U ""
http://www.linuxprinting.org/download/foomatic/foomatic-filters-ppds-current.tar.gz -U ""
Line 175: Line 177:
[bash] # cd /
[bash] # cd /
[bash] # rm -Rf /tmp/foomatic-filters-ppds*
[bash] # rm -Rf /tmp/foomatic-filters-ppds*
</pre>
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.


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.
[[Category:Administration Guide]]

Latest revision as of 18:55, 9 August 2011

Managing CUPS Printing Services

Fedora provides network printing solution through Common UNIX Printing System (CUPS). CUPS supports the Internet Printing Protocol (IPP) and provides a complete, platform independent printing solution for most networking environments.

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 admin@example.com
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

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.