opus
October 31st, 2003, 11:19
note: Thank you to WIntellect from over at http://freebsdforums.org for this how-to

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 system "root" username and password.

You will be asked for three pieces of information - "Name" "Location" and "Description". The "Name" is what will be used to uniquely identify the printer on the system. The "Location" and "Description" are for your convenience. Here's what I used:
Name: CX5200
Location: Local printer
Description: Epson Stylus CX5200

Next, you will be asked which "Device" - this will usually be either "/dev/lpt0" or "/dev/upt0" which are either the LPT port or USB port. Simply select whichever applies.

If you cannot see the USB port, stop CUPS, restart CUPS and restart the configuration process, ensuring the printer is turned on.

The next window will be fairly self explanatory - you will need to select the "Make" of printer you have. This is "EPSON" in my case.

Again, the next window will be self explanatory - you now need to select the "Model" of printer. This should be fairly obvious and in my case it was "Epson Stylus CX5200 Foomatic/gimp-print-ijs (recommended)"

Your printer is now setup!!! You may wish to "Configure" the printer to change default printing options or paper size, etc.

Configuring network printing - server side

Up until now, we have had no need to change the default CUPS config file "cupsd.conf". However, CUPS requires two features to be set to facilitate network printing

1) The "broadcast" option which broadcasts what printers are available to the network
2) The access privilege to the directories, that allows other boxes to use the local printer

First find "cupsd.conf" and open it for editing, on my FreeBSD it's in /usr/local/etc/cups/cupsd.conf.

1) To set the "broadcast", you need to edit the "BrowseAddress" option. You can set it to work based on IP address ranges, for example 10.0.0.* network ranges would be:

code:
BrowseAddress 10.0.0.255


However, there is a special "Local" option for local network connections which I comfortably use, as follows:

code:
BrowseAddress @LOCAL


2) To set the access privileges you must find the "<Location />" section and add the IP addresses / range that you wish to allow to print. For a 10.0.0.* Network this would be:

code:
<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 10.0.0.*
</Location>


However, if you only wanted to allow PCs with IP addresses 10.0.0.2 and 10.0.0.3, it would be:

code:
<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 10.0.0.2
Allow From 10.0.0.3
</Location>


Configuring network printing - client side

Believe it or not, the client need only have CUPS installed. As long as its IP address (or range) is in the server's "<Location />" list, and the server is "broadcasting" to the correct IP range then the client can use that printer. This means different OS's (especially UNIX variants) can print to printers on different systems via CUPS.

Servers printing on client local printers

You may have a workstation system with a local printer attached and configured with CUPS, and a production server that you would like to print to the workstation printer. This follows the above example in the same way, however, the workstation is then classed as the "server side" and the production server as the "client side".

__________________
http://www.bsdnexus.com/

UNIX is user-friendly; it's just picky about its friends!!!
UNIX is simple; it just takes a genius to understand its simplicity!!!

ticktock
November 17th, 2003, 16:05
went through the steps listed and had a delta when I got to the server config using the browser. Login okay but no questions as stated. Tried to add a printer and add class and typed in the info and got a.....

"Request Enity Too Large"
"The request is too large for this server to process"

What should I do?