The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
CUPS (Common UNIX Printing System) - installation and configuration --- by Gerard Samuel 13 November 2002
Need more help on this topic? Click here
This article has 15 comments
Show me similar articles

Well I am no article writer, but I decided to write down the steps I took to setup up a usb printer (HP DeskJet 640C) to a FreeBSD Server, and to be able to print from another FreeBSD workstation running KDE or Windows 2k/XP workstation from within my LAN. At first I tried an apsfilter/LPRng combo, but couldn't get past the test page. So I turned to CUPS. Their online manual, seemed pretty complete, so if you run into any problems, check out the manual first. I am going to assume Samba is installed and working.

Take a deep breath....

  1. Build a new kernel with usb/printer support on both server and workstation. Note: GENERIC kernel config files should already have these options.
        # USB Stuff
        device          usb
        device          uhci
        device          ulpt
    Note: To determine whether you need device uhci or device ohci try checking dmesg:
        hivemind# dmesg | grep uhub
        uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
  2. Edit /etc/rc.conf and add if its not already there ->
        usbd_enable="YES"
    Make sure the device node ulpt0 exists under /dev. If not, create it.
        cd /dev && ./MAKEDEV ulpt0
  3. Reboot for the new kernel and rc.conf changes to take effect.
  4. ON SERVER: Edit /etc/make.conf and add
        WITHOUT_X11=yes
  5. Install ghostscript
        cd /usr/ports/print/ghostscript-gnu && make install distclean
    Note: During my setup, I didn't modify /etc/make.conf. I just installed /usr/ports/print/ghostscript-gnu-nox11. I was told that setting WITHOUT_X11=yes would be an alternative if x11 isn't desired on the server, which /usr/ports/print/ghostscript-gnu tries to install.
  6. ON WORKSTATION: Install ghostscript
        cd /usr/ports/print/ghostscript-gnu && make install distclean
  7. Install CUPS
        cd /usr/ports/print/cups && make install distclean
  8. Move /usr/local/bin *before* /usr/bin in all user's path that will be using CUPS. It depends on what shell each particular user is using. For example. On the server, I edited root's path in /root/.profile On my workstation, I edited my shell (tcsh) ~/.tcshrc You will have to log out and log back in for the changes to take effect.
  9. Copy cupsd.sh.sample to cupsd.sh
        cp /usr/local/etc/rc.d/cups.sh.sample /usr/local/etc/rc.d/cups.sh
  10. CUPS can be administered via a web browser. By default, CUPS is looking for web admin requests from localhost. So on the server, I edited /usr/local/etc/cups/cupsd.conf and changed 127.0.0.1 to the ip address for my workstation in 2 places.
  11. Uncomment application/octet-stream in /usr/local/etc/cups/mime.types and /usr/local/etc/cups/mime.convs
  12. Uncomment BrowseAddress @LOCAL in /usr/local/etc/cups/cupsd.conf
  13. Start CUPS
        /usr/local/etc/rc.d/cupsd.sh start
  14. Check for running CUPS

        hivemind# ps aux | grep cupsd
        root  183 0.0 0.8 3852 3048 ?? Ss Mon04PM  0:15.05 /usr/local/sbin/cupsd
        root 9838 0.0 0.1 1068  540 p0 S+  7:29PM  0:00.00 grep cupsd
  15. Browse to your server's web admin, Add Printer, and follow the directions. http://your_server_name_or_ip:631/admin/ I used USB Printer #1 in my case.
  16. Browse to your workstation, Manage Printers. If all went well in the preceding steps, the printer on the server should be automatically configured on the workstation. http://localhost:631/admin/ If there are no printers setup, click Add Printer and use Internet Printing Protocol. ipp://server_hostname_or_ip/ipp/
  17. Print a test page. If all went well, you should be able to print from your FreeBSD server via the command line and workstation via the command line and/or KDE/mozilla/etc without any problems now.
        gladiator# echo This is a test > ~/test_page.txt
        gladiator# lpr ~/test_page.txt
To be able to get windows computers in the mix, you need Samba installed on the server. Then edit /usr/local/etc/smb.conf
  1. Add to the [global] section:
        printcap name = cups
        printing = cups
  2. Add a printer section
        [Printer]
            comment = Network Printer
            path = /var/spool/samba
            guest ok = Yes
            printable = Yes
Restart Samba and your windows boxes should see the printer. Install the printer driver for windows, and you should be set.

Need more help on this topic? Click here
This article has 15 comments
Show me similar articles