Setting up CUPS

DISCLAIMER: If you have a parallel port printer it might have conflicts with your motherboard. Search for "stray irq 7" in mailing lists and you should be able to find more technical information. I have not found a solution, and if your printer allows other types of connections (like USB) I recommend you try those first. Otherwise go ahead and use the Parallel port, but be warned, if it doesn't work right (it prints sometimes, but often halts to a snail pace) then this is probably the issue you are having.

CUPS is the most commonly used printing system for UNIX and UNIX-like operating systems, and allows us to use many printers we would otherwise have a lot of trouble using. Go here in order to see if you have a supported printer before continuing. As root:

vi /etc/make.conf

There are three lines to add to the file:

CUPS_OVERWRITE_BASE=yes
NO_LPR=yes
WITH_CUPS=yes

Now whenever we make ports, if those lines are applicable, they will be used. They are applicable in cups-lpr, one part of cups. The first line makes the new lpr be used instead of the system default one (which won't work) and the second defines not to rewrite the base lpr files during a make world. The third will give us a lot of drivers when we use gutenprint.

whereis cups
cd /usr/ports/print/cups
make install clean

If you've already installed Gimp you can skip this part, as you already have gutenprint. Otherwise, install it as follows.

whereis gutenprint
cd /usr/ports/print/gutenprint
make install clean

Gutenprint gives us many PPD (Postscript Printer Definition) files, which allow us to use a huge array of printers. They are installed with gimp or gutenprint.

Another rich source of printer drivers is foomatic. In order to be able to use foomatic printer drivers with CUPS, we have to install foomatic-filters:

cd /usr/ports/print/foomatic-filters
make install clean

At this point we can use foomatic printer drivers. To gain access to a huge list of foomatic printer drivers accessible within CUPS itself (i.e. no need to manually download each driver), install the following:

cd /usr/ports/print/foomatic-db
make install clean
cd /usr/ports/print/foomatic-db-engine
make install clean

Now it's time to do some CUPS configuring:

cd /usr/local/etc/cups
chmod 644 cupsd.conf
vi cupsd.conf

The first thing we want to set is the BrowseAddress appropriately for our printing setup. I wanted to give printing access to all other clients on my LAN. So I had to add this line:

BrowseAddress 192.168.1.255

That lets all clients with an IP address beginning with 192.168.1 use my printer. Change for your needs of course. If you want to keep things neat, and put it in the proper section use the following command:

/BrowseAddress

Which will search down to "BrowseAddress". It should only require a little bit of scrolling to see the options now. To continue searching, just hit n again after you hit enter. To set the browsing options of the web interface for CUPS edit this section:

<Location />
Order Deny,Allow
Deny From All
Allow from 192.168.1.*
</Location>

If you have a USB printer, there are a few more things we need to do in order to make it work with CUPS (similar info can be found in print/cups-base/pkg-message):

vi /etc/devfs.rules

Add the following lines (the top may already exist if you followed our instructions on user mounting):

[login=100]
add path 'unlpt*' mode 0660 group cups
add path 'ulpt*' mode 0660 group cups
add path 'lpt*' mode 0660 group cups

If you have another line in this section about /dev/da0s1 don't worry about it. Simply add the three CUPS lines either above or below it. Save your changes and exit. Then,

vi /etc/rc.conf

If you followed our section on user mounting, you'll already have the following line. If not, add it at this time:

devfs_system_ruleset="login"

Save your changes and exit.

NOTE: it goes without saying that if you plan to use a USB printer, you need to have USB support for your system. FreeBSD has had USB support built into the kernel by default since at least version 4.10, and probably longer. If you built a custom kernel and purposely removed USB support from it, you know what you need to do. Most of us, however, are almost finished.

It's now time for us to start CUPS:

/usr/local/etc/rc.d/cupsd start

Now we will set cups to start up every time our machine does.

vi /etc/rc.conf

Add this line:

cupsd_enable="YES"

If you are using a static IP address on the server there is a step you will need to take on any client machine that wants to print to your server. You will need to add the server to your hosts file.

vi /etc/hosts

Now add the following line, adjusted for your server.

192.168.1.100 bsd.domain.actdsltmp bsd

The first part is the IP address, the second is the hostname, while the third is your abbreviated hostname. If you don't know the hostname of the server you can check /etc/rc.conf and look for the most recent hostname.

At this point CUPS is set up. The next thing you'll probably want to do is add a printer to CUPS.