linux cups网络打印机,基于CUPS的网络打印服务器

开发板上启动cups的命令为

/etc/init.d/cups stop/start

或service cups restart1.1.23

有时出现cups web管理界面没有响应,需要重启服务。开发板里面的cups目前为1.2.7版本,需要研究与高版本存在的差异。

3、手动安装的cups打印机的一些命令,范例:

/usr/sbin/lpadmin -p LaserJet -E -v parallel:/dev/lp0 -m laserjet.ppd

1.添加名为LaserJet的打印机(-p)

2.启用要使用的打印机(-E)

3.设置要使用的设备和设备类型(-v)

4.使用驱动程序/PPD文件laserjet.ppd (-m)

字符下打印:

/usr/bin/lp -d LaserJet /etc/aliases

lp语法将文件/etc/aliases打印到LaserJet打印机(-d)。

临时禁用和启动打印机:

/usr/bin/disable -r "Changing Paper" LaserJet

/usr/bin/enable LaserJet

CUPS配置

注意,不同的版本界面略有差异,本文所用的软件版本为1.3.9。cups在很多Linux版本中已自带,不需要额外安装。

进入Administration,点击“Add printer”。

选择正确的驱动程序,如果所连接打印机的驱动程序不存在,则必须手工添加驱动程序(略)。

在添加打印机的最后,会提示你输入Linux的root用户名和密码。

从下图可以看到新添加的打印机,名称为test。

重要提示:

1)打开选择administration,基本管理设置中Show printers shared by other systems,Share published printers connected to this system,Allow printing from the Internet这三项选定,即许可共享本地打印机,许可其它操作系统连接和许可网络打印。见【cups提供远程打印服务的配置经验】cups1.3.3。(好像并不是必须的)

2、编辑/etc/cups/cupsd.conf在Location选项添加容许的windows网段。

3、编辑/etc/cups/mime.convs,找到如下一行(很重要,否则会显示答应错误)

#application/octet-stream application/vnd.cups-raw 0 -

将注释去掉。

4、编辑/etc/cups/mime.type,找到如下一行(好像默认并没有注释)

#application/octet-stream

同3一样,将注释去掉。

1、Windows客户端

在使用cups连接的网络打印服务前,必须停止XP的防火墙服务,或添加631的协议。否则会引起问题的。安装步骤如下:

1)在弹出的对话框中选择“添加打印机”

2)选择添加的打印机类型为“网络打印机”

3)在URL下输入地址:,其中10.2.2.3为cups打印服务器的IP地址,631为cups服务端口,ll为添加的打印机的名称。

4)如果提示URL错误,请纠正。否则点击“下一步”,然后提供Windows下的打印机驱动即可。

以上配置在cups1.3.9下测试完成,不敢保证在cups其他版本是否一定通过。

2、Linux客户端

对于已联网并且安装了CUPS的Linux客户端来讲,能够自动检测到网络中的打印机。因此,只需要找到菜单“系统——>首选项——>更多首选项——>默认打印机>”(redhat enterprise server)或“桌面——>首选项——>更多首选项——>默认打印机>”(fedora),将弹出网络上所有已存在的打印机,选择其中的某一在线打印机作为默认打印机即可。

090505215255.jpg

网上提到在客户端要打开631端口或关闭防火墙,显然是错误的。应该是在服务器端打开631端口即可,是否关闭整个防火墙,笔者认为没有必要,不过调试过程中建议disable,以免对调试进度产生不利影响。

如果Linux客户端没有安装CUPS,则需要手工去添加打印机,笔者没有做过研究,网上有一篇文章(http://blog.sina.com.cn/s/blog_5507289e010008ky.html),有兴趣的可以参考。

也可以使用samba服务来共享打印机,这是最常规的做法,只需配置samba服务,将打印机共享即可。

security = share

########## Printing ##########

# If you want to automatically load your printer list rather

# than setting them up individually then you'll need this

#;load printers = yes

load printers = yes

# lpr(ng) printing. You may wish to override the location of the

# printcap file

;printing = bsd

;printcap name = /etc/printcap

# CUPS printing.See also the cupsaddsmb(8) manpage in the

# cupsys-client package.

printing = cups

printcap name = /etc/printcap

# When using [print$], root is implicitly a 'printer admin', but you can

# also give this right to other users to add drivers and set printer

# properties

;printer admin = @ntadmin

############ Misc ############

# Using the following line enables you to customise your configuration

# on a per machine basis. The %m gets replaced with the netbios name

# of the machine that is connecting

;include = /home/samba/etc/smb.conf.%m

# Most people will find that this option gives better performance.

# See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/speed.html

# for details

# You may want to add the following on a Linux system:

#SO_RCVBUF=8192 SO_SNDBUF=8192

socket options = TCP_NODELAY

# The following parameter is useful only if you have the linpopup package

# installed. The samba maintainer and the linpopup maintainer are

# working to ease installation and configuration of linpopup and samba.

;message command = /bin/sh -c '/usr/bin/linpopup "%f" "%m" %s; rm %s' &

# Domain Master specifies Samba to be the Domain Master Browser. If this

# machine will be configured as a BDC (a secondary logon server), you

# must set this to 'no'; otherwise, the default behavior is recommended.

;domain master = auto

# Some defaults for winbind (make sure you're not using the ranges

# for something else.)

;idmap uid = 10000-20000

;idmap gid = 10000-20000

;template shell = /bin/bash

#======================= Share Definitions =======================

[homes]

comment = Home Directories

browseable = no

# By default, the home directories are exported read-only. Change next

# parameter to 'yes' if you want to be able to write to them.

writable = no

# File creation mask is set to 0700 for security reasons. If you want to

# create files with group=rw permissions, set next parameter to 0775.

create mask = 0700

# Directory creation mask is set to 0700 for security reasons. If you want to

# create dirs. with group=rw permissions, set next parameter to 0775.

directory mask = 0700

# Un-comment the following and create the netlogon directory for Domain Logons

# (you need to configure Samba to act as a domain controller too.)

;[netlogon]

;comment = Network Logon Service

;path = /home/samba/netlogon

;guest ok = yes

;writable = no

;share modes = no

# Un-comment the following and create the profiles directory to store

# users profiles (see the "logon path" option above)

# (you need to configure Samba to act as a domain controller too.)

# The path below should be writable by all users so that their

# profile directory may be created the first time they log on

;[profiles]

;comment = Users profiles

;path = /home/samba/profiles

;guest ok = no

;browseable = no

;create mask = 0600

;directory mask = 0700

[printers]

comment = All Printers

browseable = yes

path = /var/spool/samba

printable = yes

public =yes

writable = no

create mode = 0700

# Windows clients look for this share name as a source of downloadable

# printer drivers

[print$]

comment = Printer Drivers

path = /var/lib/samba/printers

browseable = yes

read only = yes

guest ok = no

# Uncomment to allow remote administration of Windows print drivers.

# Replace 'ntadmin' with the name of the group your admin users are

# members of.

;write list = root, @ntadmin

按照以上修改后,根据IP地址搜索计算机,应该可以找到打印服务器。

进入后能看到所有的打印机列表,选择其中一款打印机,点击连接即可。

(注:图片太多,不一一上传,太花时间)