分享
 
 
 

CupsHowto

王朝other·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

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 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".

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有