当前位置:操作系统 > Unix/Linux >>

CupsHowto

All,

  In the past I have answered a few questions about CUPS. Seeing as I'm now doing "HOWTO"s on my webserver, here's one for CUPS installation, configuration and network printing.

  I hope it's of use to someone

  -----------------------------------------------------------------------------------------

  Preamble

  This HOWTO will show you how to complete a basic install of CUPS, the Common UNIX Printing System, a local printer and network printing - the server will be running FreeBSD.

  First - choose the right printer; visit www.linuxprinting.org

  Believe it or not, your choice of printer will determine whether or not you can use it on UNIX with CUPS. Certain printer manufacturers have been very supportive of the open source community, others have not. A website has been created that lists all printers which function with CUPS and also to what extent, it's www.linuxprinting.org.

  Visit the site and choose a printer (if you haven't already bought one) that is classed as working "perfectly". I bought an Epson Stylus CX5200 based upon this website - here's what the database says about the Epson CX5200

  So you've got the printer - let's get it to work.

  Install CUPS - and supporting applications

  I'm a great fan of the ports collection on FreeBSD - and why ignore the fact that someone else has made the effort to make sure you can install the software you want/need? Change into the "cups" directory of ports, change to "root" and install the application:

  code:--------------------------------------------------------------------------------

  cd /usr/ports/print/cups

  su

  Password: ********

  make install clean

  --------------------------------------------------------------------------------

  In my experience of CUPS, there are a number of useful drivers/applications which are often required to get certain printers working. So, we'll install them too. Again, the ports system is our friend, so run the command "make install clean" in the following directories too:

  code:--------------------------------------------------------------------------------

  /usr/ports/print/gimp-print

  /usr/ports/print/hpijs

  /usr/ports/print/ghostscript-gnu

  /usr/ports/lang/perl5

  --------------------------------------------------------------------------------

  A quick visit back to linuxprinting.org

  Linuxprinting.org has another feature that makes it extra special - it has a database of the "PPD"s that CUPS uses as printer configuration files. So - next you need to go back to the website, select your printer from the database and choose the option to "download PPD".

  In the case of my CX5200, the PPD is called 'Epson-Stylus_CX5200-gimp-print-ijs.ppd'. This file needs to be placed in the CUPS "model" directory. This directory stores all PPD files. In FreeBSD this directory is /usr/local/share/cups/model:

  code:--------------------------------------------------------------------------------

  chown root:wheel Epson-Stylus_CX5200-gimp-print-ijs.ppd

  chmod 644 Epson-Stylus_CX5200-gimp-print-ijs.ppd

  mv Epson-Stylus_CX5200-gimp-print-ijs.ppd /usr/local/share/cups/model

  --------------------------------------------------------------------------------

  Getting "foomatic"

  The Foomatic filter script is called by CUPS with various inputs; inputs include both the PPD filename and the various options selected by the user. foomatic-rip opens the PPD, extracts all options and their possible settings and also the command line to execute Ghostscript with the appropriate driver. It parses the PostScript print file for option settings. It also massages the standard CUPS option types into the more generic printer/driver-specific format used by the database. Therefore, we need to install it. You need to obtain these two files:

  http://www.linuxprinting.org/foomatic-rip

  http://www.linuxprinting.org/foomatic-gswrapper

  These files need to be moved to the right location with the right modes applied:

  code:--------------------------------------------------------------------------------

  mv foomatic-rip /usr/local/bin

  mv foomatic-gswrapper /usr/local/bin

  cd /usr/local/bin

  chmod 755 foomatic-rip foomatic-gswrapper

  --------------------------------------------------------------------------------

  Next, you need to ensure that both file's first line points correctly to Perl. This can be done with the command "whereis perl". In my case, Perl is found in /usr/bin/perl, so the first line should look like:

  code:--------------------------------------------------------------------------------

  #!/usr/bin/perl

  --------------------------------------------------------------------------------

  Finally, foomatic must be reachable by CUPS, this is achieved by placing a softlink in CUPS's "filter" directory. On my FreeBSD machine, this is found as /usr/local/libexec/cups/filter:

  code:--------------------------------------------------------------------------------

  ln -s /usr/local/bin/foomatic-rip /usr/local/libexec/cups/filter/foomatic-rip

  --------------------------------------------------------------------------------

  Hide the BSD lp commands

  CUPS will have installed its own versions of the commands "LP" "lpr" "lpq" "lprm". These will cause a BIG conflict with the BSD installed versions of these commands. Therefore, we must remove/hide the BSD commands so that only the CUPS commands are used.

  On my FreeBSD box, the BSD commands are in "/usr/bin" whereas the CUPS commands are in "/usr/local/bin", this means we can simply backup the BSD ones as follows:

  code:--------------------------------------------------------------------------------

  mv /usr/bin/lp /usr/bin/lp.bak

  mv /usr/bin/lpr /usr/bin/lpr.bak

  mv /usr/bin/lprm /usr/bin/lprm.bak

  mv /usr/bin/lpq /usr/bin/lpq.bak

  --------------------------------------------------------------------------------

  NB: You will have to redo this step EVERY time you rebuild world in FreeBSD.

  Configuring the printer

  I've only found one reservation with CUPS - USB printers must be plugged in and switched on BEFORE CUPS is started, otherwise it cannot be configured. Once configured it doesn't matter though. So, if your printer is a USB printer, you MUST plug it in and turn it on before proceeding.

  The startup script needs to be renamed in FreeBSD so that CUPS will start at (nonexistent) reboots:

  code:--------------------------------------------------------------------------------

  mv /usr/local/etc/rc.d/cups.sh.sample /usr/local/etc/rc.d/cups.sh

  --------------------------------------------------------------------------------

  The server can now be started with the following command:

  code:--------------------------------------------------------------------------------

  /usr/local/etc/rc.d/cups.sh start

  --------------------------------------------------------------------------------

  The server can be configured with the aid of a web browser - simply point it at: http://localhost:631/admin

  This brings up the main CUPS admin interface, when asked to log in, use your sy
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,