配置cups
1. 访问控制
中央 cups 守护程序配置文件是 /etc/cups/cupsd.conf 。
它的语法类似于 Apache 网络服务器配置文件所需的语法。
决定谁可以打印的访问控制是使用位置部分配置的,即:
<Location /> Order Deny,Allow Deny From All Allow From 127.0.0.1 </Location>
首先处理拒绝语句,然后是允许语句。
默认情况下,除本地主机 127.0.0.1 外,所有主机都拒绝访问。
在下面的示例中,来自 localhost (127.0.0.1) 和网络地址空间 10.182.121.0/25 的主机被允许使用系统上的打印机。
<Location /> Order Deny,Allow Deny From All Allow From 127.0.0.1 Allow From 10.182.121.0/25 </Location>
2. 配置工具
一旦cups 守护进程启动,CUPS 就可以通过它的Web 界面http://localhost:631 进行配置。
如果出现提示,请输入根凭据。
通过单击“管理”和“添加打印机”按钮,可以将打印机添加到 CUPS 配置中。
Web 界面会提示其他打印机信息,即:
命名打印机的名称。
位置 打印机的物理位置。
描述 打印机的描述
单击“继续”按钮以配置打印机的连接方式。
配置打印机端口后,选择打印机品牌和型号。
打印机配置完成后,打印机将添加到 CUPS 配置中。
以下是添加打印机后的示例 cups 配置文件:
$ cat /etc/cups/printers.conf # Printer configuration file for CUPS v1.3.5 # Written by cupsd on 2008-04-01 11:14 <Printer Printer> Info HP printer <- PRINTER BRAND AND MODEL Location 2nd Floor <- LOCATION DeviceURI parallel:/dev/lp0 <- PRINTER ATTACHED TO LOCAL MACHINE State Idle StateTime 1207041285 Accepting Yes Shared Yes JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 OpPolicy default ErrorPolicy stop-printer </Printer>
相应的条目现在出现在 /etc/printcap 文件中,即:
$ cat /etc/printcap # This file was automatically generated by cupsd(8) from the # /etc/cups/printers.conf file. All changes to this file # will be lost. Printer|HP printer:rm=hostname.cn.oracle.com:rp=Printer:
注意:不要编辑 /etc/printcap 文件或者位于 /etc/cups/ 目录中的文件。
每次启动或者重新启动 cups 守护程序时,都会动态创建新的配置文件。
当使用系统打印配置工具应用更改时,这些文件也会动态重新创建。
服务控制
管理 cups 服务的脚本是 /etc/init.d/cups 。
在需要打印的地方,启用 cups 服务以在服务器启动时自动启动,即:
# chkconfig --add cups # chkconfig --list cups cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
启用服务 cups-lpd,即:
# chkconfig cups-lpd on
用法:
# service cups Usage: cups {start|stop|restart|condrestart|reload|status}
例子:
# service cups status cupsd (pid 2308) is running...
# service cups stop Stopping cups: [ OK ]
# service cups start Starting cups: [ OK ]
# service cups restart Stopping cups: [ OK ] Starting cups: [ OK ]
# service cups condrestart Stopping cups: [ OK ] Starting cups: [ OK ]
# service cups reload Reloading cups: [ OK ]
# service cups status cupsd (pid 3689) is running...
服务启动后,cupsd 守护进程会运行,监听它的默认端口 631,例如:
# ps -aux|grep cupsd root 17591 0.0 0.7 9704 2080 ? Ss 02:48 0:00 cupsd
# netstat -anp|grep cups tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 17591/cupsd udp 0 0 0.0.0.0:631 0.0.0.0:* 17591/cupsd
cups服务说明
通用 UNIX 打印系统 (“CUPS”) 是适用于所有 UNIX 环境的跨平台打印解决方案。
它基于“Internet 打印协议”,为大多数 PostScript 和光栅打印机提供完整的打印服务。
CUPS 是 LPD 打印系统的替代品。
它用自己的版本替换 lpr 命令,用自己的版本替换 LPD 打印机驱动程序。
但是,CUPS 与 LPD 的相似之处在于它使用 PostScript 作为其页面描述的基础语言。
Linux(和 UNIX)程序不知道 CUPS 和 LPD 之间的区别。
此服务执行打印机服务器守护程序。
守护进程将有关其打印机和类的信息广播到本地网络。
本地网络中运行 CUPS 守护程序的每台机器都会接收这些信号。
因此,它知道本地网络中有哪些打印机可用。
所以 CUPS 客户端只需要启动它的 CUPS 守护进程,它就可以访问本地网络上的所有打印机。
# yum install cups # yum install cups-lpd