CentOS 5.9下配置CUPS打印机IPP共享

上学的时候打印都是找别人,工作后公司的打印机不支持网络打印,每次都是笔记本直接连接打印机进行打印,老大让想想办法,于是就找到了CUPS这家伙。

一:安装CUPS

1 先看打印机是否支持linux

首先到 http://www.openprinting.org/printers 查询一下你的打印机是否支持linux,没想到我们的打印机既然是完美支持。
打印机型号:Brother-MFC-7450
完美支持,有3个小企鹅标志:http://www.openprinting.org/printer/Brother/Brother-MFC-7450
既然这样那就不多说了直接配置CPUS了,听官方的:
"""
文档地址:
http://www.linuxfoundation.org/collaborate/workgroups/openprinting/database/cupsdocumentation

In most cases you do not need to go through these steps. Modern Linux distributions have everything prepared for using most printers. For USB printers it is often enough to simply plug them in. The printer gets auto-detected and after some seconds a message pops up on the screen telling that the printer is set up. If this is not the case or for parallel or network printers you simply start the distribution's printer setup tool out of the system administration menu or out of a system administration application, click on a button for adding a new printer and then follow the screen instructions. In certain cases PPDs or drivers are even automatically downloaded from this web site.

If this does not work, usually there is no suitable driver installed on your system. Verify in the OpenPrinting database whether your printer is supposed to work and whether there is a driver or PPD file available.

0.  First just give it a try.
Start at Step 5 (Configure CUPS). See if this works before installing new software; most distributions ship many drivers and PPD files.
"""

2 安装CUPS

yum -y install cups-libs cups

二: 配置CUPS

1 默认web配置只对localhost开放,需要编辑配置文件来打开,修改cupsd.conf如下:

#
# "$Id: cupsd.conf.in 7199 2008-01-08 00:16:30Z mike $"
#
#   Sample configuration file for the Common UNIX Printing System (CUPS)
#   scheduler.  See "man cupsd.conf" for a complete description of this
#   file.
#

# Log general information in error_log - change "info" to "debug" for
# troubleshooting...
LogLevel info

# Administrator user group...
SystemGroup sys root


# Only listen for connections from the local machine.
#Listen localhost:631
Listen *:631
Listen /var/run/cups/cups.sock

# Show shared printers on the local network.
Browsing On
#BrowseOrder allow,deny
BrowseOrder deny,allow
# (Change '@LOCAL' to 'ALL' if using directed broadcasts from another subnet.)
BrowseAllow @LOCAL
#BrowseAddress @LOCAL
#Allow @LOCA

# Default authentication type, when authentication is required...
DefaultAuthType Basic
DefaultEncryption IfRequested

# Restrict access to the server...
<Location />
  #Order allow,deny
  Order deny,allow
  Deny From All
  Allow From 127.0.0.1
  Allow From 192.168.1.*
  Allow @LOCAL
</Location>

# Restrict access to the admin pages...
<Location /admin>
  #Encryption Required
  #Order allow,deny
  Encryption Never
  Order deny,allow
  Deny From All
  Allow From 127.0.0.1
  Allow From 192.168.1.*
  Allow @LOCAL
</Location>
# Restrict access to configuration files...
<Location /admin/conf>
  #AuthType Default
  #Require user @SYSTEM
  #Order allow,deny
  Encryption Never
  AuthType Default
  Require user @SYSTEM
  Order deny,allow
  Deny From All
  Allow From 127.0.0.1
  Allow From 192.168.1.*
  Allow @LOCAL
</Location>

# Set the default printer/job policies...
<Policy default>
  # Job-related operations must be done by the owner or an administrator...
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

# All administration operations require an administrator to authenticate...
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # All printer operations require a printer operator to authenticate...
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>

  # Only the owner or an administrator can cancel or authenticate a job...
  <Limit Cancel-Job CUPS-Authenticate-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>

  <Limit All>
    Order deny,allow
  </Limit>
</Policy>

MaxLogSize 2000000000

#
# End of "$Id: cupsd.conf.in 7199 2008-01-08 00:16:30Z mike $".
#

2 为了通过HTTP/IPP方式共享给Windows方式主机使用,还需要修改文件制式

vim /etc/cups/mime.types 
取消对文末
application/octet-stream
的注释

vim /etc/cups/mime.convs 
取消对文末
application/octet-stream application/vnd.cups-raw 0 -
的注释

RAW模式不启用,你在/var/log/message里面就会看见报错的
这样的 打印机已经可以通过HTTP/IPP的方式共享了

3 用CUPS管理打印机

输入地址 http://192.168.1.49:631/ 选择添加打印机,按照步骤进行添加。
添加完毕后你的打印机会对应一个网络地址,例如我的是:http://192.168.1.49:631/printers/Brother_MFC-7450_USB_1

4 挺有意思的命令,查找打印机信息

[root@printserver cups]# lpinfo -v
network socket
network beh
direct usb://Brother/MFC-7450
network http
network ipp
network lpd
direct parallel:/dev/lp0
direct scsi
serial serial:/dev/ttyS0?baud=115200
serial serial:/dev/ttyS1?baud=115200
network smb

三: windows平台下的使用

这是关键,花费这么长的时间,不就是为了可以在windows 7下直接实现网络打印,具体过程如下:

确信自己已经安装了打印机的驱动,例如我的是Brother_MFC-7450,就先安装Brother_MFC-7450 for windows 7 的驱动
然后 控制面板---》查看设备和打印机==》添加打印机
一:添加网络打印机
二:选择 【我需要的打印机不在列表】中
三:选择 【按名称选择共享打印机】 ,  填写你的打印机地址,我的是http://192.168.1.49:631/printers/Brother_MFC-7450_USB_1就填写这个。
四:驱动选择 MFC-7450,点击 确定,结束。

四:是时候结束了

自言自语:

好了,想想是不是该结束了,每次看别人的文章感觉写的是那么的不清晰,那么的乱。轮到自己写了,绞尽脑汁,写的任然是惨不忍睹,可见真是说着容易做着难啊,慢慢提高自己的逻辑表达思维吧。如果参考了本篇文章,没有试验成功,勿怪。

参考资料:

CentOS 5.5 配置CUPS打印机IPP/SAMBA共享: http://blog.ihipop.info/2010/12/1946.html

linux下samba共享打印机:http://blog.csdn.net/linglongwunv/article/details/5213030

鸟哥 CUPS:http://linux.vbird.org/linux_basic/0610hardware.php#cups

OpenPrinting CUPS Quick Start:http://www.linuxfoundation.org/collaborate/workgroups/openprinting/database/cupsdocumentation