debian 安装打印机驱动及打印机共享

88 篇文章 0 订阅

作者:wzb56

转自:http://blog.csdn.net/wzb56/article/details/7677604


为了局域网可以共享Debian Linux 服务器上打印机,下面通过cups(common unix printing system)实现的。

debian安装打印机的cups服务及驱动的一般步骤:

<1>安装驱动的相关cups的服务:

 终端运行:

 sudo apt-get install cups cups-client cups-bsd foomatic-filters  # 通常这些软件都是系统默认已经装好的.

<2>安装打印机驱动.

比如HP的驱动直接: 

sudo apt-get install hpijs  hplip  #有的建议不要安装这两个驱动

可以参考:http://foo2zjs.rkkda.com/ 网站上安装驱动程序的说明

Download and Install

Click the link, or cut and paste the whole command line below to download the driver.
    $ wget -O foo2zjs.tar.gz http://foo2zjs.rkkda.com/foo2zjs.tar.gz

Now unpack it:

Unpack:
    $ tar zxf foo2zjs.tar.gz
    $ cd foo2zjs

Now compile and install it. The INSTALL file contains more detailed instructions; please read it now.

Compile:
    $ make

Get extra files from the web, such as .ICM profiles for color correction,
and firmware.  Select the model number for your printer:
    $ ./getweb cpwl	# Get Minolta Color PageWorks/Pro L .ICM files
    $ ./getweb 2200	# Get Minolta 2200 DL .ICM files
    $ ./getweb 2300	# Get Minolta 2300 DL .ICM files
    $ ./getweb 2430	# Get Minolta 2430 DL .ICM files

    $ ./getweb 1000	# Get HP LaserJet 1000 firmware file
    $ ./getweb 1005	# Get HP LaserJet 1005 firmware file
    $ ./getweb 1018	# Get HP LaserJet 1018 firmware file
    $ ./getweb 1020	# Get HP LaserJet 1020 firmware file

    $ ./getweb 1025	# Get HP LaserJet Pro CP1025nw .ICM files

Install driver, foomatic XML files, and extra files:
    $ su			OR	$ sudo make install
    # make install

(Optional) Configure hotplug (USB; HP LJ 1000/1005/1018/1020):
    # make install-hotplug	OR	$ sudo make install-hotplug

(Optional) If you use CUPS, restart the spooler:
    # make cups			OR	$ sudo make cups

<3> 驱动安装成功后,开启cups服务:

sudo /etc/init.d/cups restart    

开启成功后,在浏览器中直接访问http:\\localhost:631 

即可看到配置页面.一路点击增加一个打印机,选择对应的打印机,一路点下去

,直到最后一步选择打印机的model,选择已经安装好的驱动

 带hpijs的那个(或在下拉中选中自己型号对应的系统默认驱动).一个打印机便添加完成了.

用open office或者gedit 就可以打印了.

打印成功后,整个局域网都可以共享使用这个打印机,客户机可以windows,可以是linux. 那么共享的地址究竟是何呢? 谁有权限访问cups的打印机及管理地址呢?

在debian主机的/etc/cups/cupsd.conf文件中,我们完全可以设置这些选项:

一 端口:

#将

#Listen localhost:631

#修改成

Listen 0.0.0.0:631

二 共享权限

#将

#<Location />

# Order allow,deny

# Allow localhost

#</Location>

#修改成

<Location />

Order deny,allow

Allow From 192.168.1.*

</Location>

保存好,然后sudo /etc/init.d/cups restart .

在浏览器中输入http://debian主机的ip:631/printers

 敲击回车选择对应的打印机, 复制打印机地址,

形如:http://192.168.1.102:631/printers/Officejet-5600-series 这便是网络打印机的地址

windows如何共享呢? 也很简单,

网上很多资料说需要linux安装samba共享,其实没有必要,cups本身就是专门作为打印服务器的,自带这些功能,

不要小看这个631端口,这个服务出品自apple公司.

首先windows需要先安装打印机的windows驱动程序.

安装好后,添加网络打印机,

然后选择第二项:连接到这台打印机,在文本框中把刚刚的打印机地址输入进来,

随便选择一个打印机的驱动,只要能一直点击到最后即可.

这时再看到windows中的打印机,右击打印机,

在打印机的驱动的下拉表中选择对应驱动,至此,windows便可成功共享打印机.

Debian打印介绍

打印对于Linux/Unix类系统来说,曾经没有一点问题,但那是很久以前的事情了。随着各种新型打印机的出 现,特别是很多不支持 PostScript 功能的廉价打印机,曾一度使在Linux上的打印变得非常困难。但现在,情况已经完全不同了,在Linux上打印已经越来越方便,用Linux作为打印服 务器,已经成为很多大小企业的选择。

在具体讲述如何安装打印机之前,先来看一下对于打印的一些比较关键的问题。

* 打印机的命令方式:从总体上来看,打印的命令方式可以分成文本、PostScript和其它种类。所谓文本,就是那些比较古老的针式打印机,我们可以直接 cat text_file > /dev/lp0,这种打印机现在已经很少使用了,在Linux上使用这类打印机是一点问题都没有的。相信PostScript这个词大家都是听说过的, PS实际上是一种专门用语打印方面的脚本语言;能够直接支持PostScript的打印机,通常都是非常高级的办公用打印机;PS语言是计算机和这类打印 机之间沟通的方式。再有就是现在我们经常用到的各种比较低档的打印机,喷墨的或者激光的都有;它们不支持PostScript,通常都是使用厂家自己的命 令集。
* 应用程序的打印支持:Linux上的各种应用程序,都是通过输出PostScript来描述需要打印的页面的,而在将来,这种趋势不会发生任何变化。
* GhostScript:对于支持PostScript的打印机而言,要支持Linux是比较容易的,但对于那些并不支持PostScript的打印机而 言,就必须要能够把 PostScript格式的页面描述,转换成为这些打印机能够识别的打印命令。而GhostScript就是用来完成这个工作的,它能够解析 PostScript命令,并用相应的驱动来显示它们。譬如GhostScript可以把一个PS文件显示在屏幕上,也可以借助打印机厂商的驱动将PS文 件转换成打印命令。
* PPD:PPD是用来描述打印机功能的文件,要使用一款打印机之前,必须找到其PPD文件,并正确地安装到打印管理器程序上。
* 打印管理程序:作为一个多用户多任务的操作系统,Linux上的所有程序都是基于多任务、多用户而设计的,打印也不例外。为了让不同的用户、不同的任务在 打印的时候不会产生冲突,就需要一个打印管理程序。这类管理程序很多,从传统的LPD,到时下非常流行的CUPS。它们功能各异,但有一点不变的就是都是 用来协调打印任务的。CUPS的工作方式如下:通过命令行接收要打印的文件;通过文件的类型判断是否需要将其转换为PostScript,如果需要,则调 用相应的应用程序进行转换;通过PPD文件来判断GhostScript应使用何种驱动处理此PostScript文件;把GhostScript处理的 结果输出到打印设备上。
* 把一切整合在一起:由于打印领域长时间的混乱,诞生了各种打印管理程序,而要学会为每一个打印管理程序安装驱动,是一件痛苦的事情(仅仅学习CUPS却是 非常愉快的)。于是就出现了 foomatic,它的作用是通过一种方式管理所有的打印机,把PPD和打印管理程序的配置屏蔽掉,给用户一个统一的界面。

综 上所属,要在Linux上使用一台打印机,首先必须确定它被支持,然后需要选择一个打印管理程序并配置好打印驱动。最后,能否产生正确漂亮的打印 结果,则要看应用程序能否生成正确的PostScript文件。过去,有很多程序不能正确的打印中文,主要就是因为它们不能正确的处理中文的字符集或者中 文字体。下面,我会介绍在Debian上安装配置CUPS并进行打印的过程,并不包括foomatic。

用CUPS打印

Common Unix Printing System(CUPS)是一个出现的比较晚的打印管理程序,也正是如此,它的功能很现代,界面也非常友好。出现的晚,并不代表功能少和支持不广泛,CUPS拥有丰富的功能,支持各种各样的打印机,且被各种应用程序广泛地支持。

安装打印管理器

Debian 上的CUPS被分散在几个软件包中,包括库、服务器、客户端等等。连接了打印机的机器需要安装服务器,而要提交打印任务的机器,则必须安装客户端。服务器 的包是cupsys,客户端的包是cupsys-client和cupsys-bsd,前者是CUPS自己的客户端,后者是用来替换BSD的lpr命令 的,这样可以让一些比较古老的应用程序继续通过lpr命令进行打印。

通过apt-get命令分别安装打印机和服务器:

# apt-get install cupsys foomatic-filters
# apt-get install cupsys-client cupsys-bsd

foomatic-filters这个软件包对于CUPS系统来说是非常必要的,千万别忘了。

安装打印机驱动程序

这里我们所说的驱动程序,包含以下三个方面:

* PPD文件:要获得这个文件有很多的方法,但最简单的就是到http://www.linuxprinting.org去下载。同一台型号的打印机有时会 有不同的PPD文件,譬如HP LaserJet 5000就有四个,要根据硬件的情况来选择,譬如其中的PostScript类型就不能用于HP LaserJet 5000LE款的打印机上,因为这一款打印机去掉了PostScript模块。下载PPD文件后,要将其复制到安装了CUPS服务器的计算机的 /usr/share/cups/model目录中,然后重新启动CUPS的服务器。
* GhostScript驱动:GhostScript有几个版本,其中Debian缺省使用的是gs-esp。这个版本的GhostScript已经将各种Free的驱动编译到其中。
* 其它程序:如果是用HP系列的打印机,通常会需要hpijs。不同的厂商还会提供一些用于管理其打印机的程序,譬如检查墨盒容量等等,可根据自己的需要安装。

添加打印设备

安 装好打印驱动之后,下一步的工作就是把已经完成的设备添加到CUPS的打印设备列表里面。这一步可以有很多种方式,但最简单的,就是用CUPS自 己的 Web管理界面。在安装了CUPS服务器的计算机上,访问http://localhost:631/就可以了。当添加打印机时,用户需要输入账号密码, 此时可以用root账号,但只要用户在lpadmin这个组中,就可以管理打印机了。

添加的第一步是选择打印机的名称、位置、描述等,名称是比较重要的,以后都会用到。在选择完制造商后,就可以看到上述PPD文件所描述的打印机信息了,如果你找不到,可能是忘了重新启动cupsys服务。

使用

通过Web界面,可以完成全部管理打印机的操作,包括开启、关闭打印机,取消打印作业等等。如果要打印一个文件,就需要借助应用程序或者是CUPS的客户端了。

OpenOffice

OpenOffice有自己的打印配置程序,但如果你使用了CUPS,完全没有必要再去配置什么,OpenOffice可以自动识别到CUPS系统中添加的打印机。

Mozilla Firefox

Mozilla Firefox在使用打印机前,需要进行简单的设置。编辑文件/usr/lib/mozilla-firefox/defaults/pref/unix.js,并加入如下两行:

pref("font.FreeType2.enable", true);
pref("font.directory.truetype.1","/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/";

在Firefox的软件包中,上述文件并不存在,不用担心,加上就可以了。

Acrobat Reader

用Acrobat Reader使用打印机时,在其打印对话框中有Command选项,其缺省值为/usr/bin/lpr,因此用户必须安装cupsys-bsd软件包才行。如果打印时并非使用缺省的打印机和选项,则需要在这里进行自己设置。

gedit

在GNOME 2.8中,其打印组建gnomeprint已经比较成熟了。如果你现在仍然使用GNOME 2.8以前的版本,我建议你更新一下,这样gedit就可以正常地打印了。

命令行

CUPS 的命令行程序有lp、lpstat和cancel,对应的BSD打印命令行工具是lpr、lpq和lprm。这些命令行程序都有很多参数, 在 CUPS的用户手册中有详细的描述,在此就不赘述了。需要说明的是,当传递给lp的文件不是PostScript或者PDF格式时,CUPS都要选择一个 程序来将其转换为这个格式,其打印效果也就不得而知了。因此,建议用户首先想办法生成一个PS/PDF文件,然后再打印。

gtklp

要 记住lp的每一个选项还是一件挺麻烦的事情,gtklp是一个允许用户在图形界面下选择打印选项的工具。它支持所有的CUPS选项,只要点点鼠标 就可以打印啦。用户选择完毕后,它会自动调用lp命令的。gtklp软件包中还有一个gtklpq程序,通过它,可以查看和修改打印队列。

共享

共享打印机给Linux用户对于CUPS来说非常简单,只需要修改/etc/cups/cupsd.conf文件,允许其它用户访问/printer资源就可以了。我不知道Windows是否支持ipp协议,如果支持,也可以用这种方式打印。

常见的问题

1. 为何XX程序不能打印中文?

如上所属,能不能打印中文,关键在于负责生成PostScript的程序是否能够支持中文,很多老的命令行工具都是无法支持中文的,即便是新的软件,也不见得能够支持地很好。

2. 显示时的中文粗体为何打印的时候没有?

现在很多用xft/fontconfig的朋友都打了firefly的粗体补丁,但这个补丁仅仅是用在显示上的。当打印时,往往是直接从字库中提取字形信息,并嵌入到PostScript文件中的,字库里面是什么样子,打印出来就是什么样子。

3. 我的打印机,Linux支持的不是很好,怎么办?

我 有一台Mac,还有一套正版的Windows,我打电话给微软客服,但它们却告诉我如果你要使用Windows,就一定要选择跟Windows兼 容的计算机。如果你要用Linux,买硬件之前就一定要做一些简单的调查研究,对于那些技术很差根本不懂得如何支持Linux的硬件厂商的产品,就千万不 要买。http://www.linuxprinting.org上可以查到各种打印机和Linux的兼容情况,查一下,除了兼容性之外,还能知道有些打 印机为什么会便宜,而另一些为什么贵


Setup CUPS (Common UNIX Printing System) Server and Client in Debian

来自: http://www.debianadmin.com/setup-cups-common-unix-printing-system-server-and-client-in-debian.html

The Common UNIX Printing SystemTM, or CUPS, is the software you use to print from applications like the web browser you are using to read this page. It converts the page descriptions produced by your application (put a paragraph here, draw a line there, and so forth) into something your printer can understand and then sends the information to the printer for printing.

Now, since every printer manufacturer does things differently, printing can be very complicated. CUPS does its best to hide this from you and your application so that you can concentrate on printing and less on how to print. Generally, the only time you need to know anything about your printer is when you use it for the first time, and even then CUPS can often figure things out on its own.

<1> :Install CUPS printer server in Debian

#apt-get install cupsys cupsys-driver-gutenprint foomatic-db-gutenprint foomatic-filters fontconfig libtiff4 libfreetype6

NOTE:- If your network use DHCP it's a good idea to set up your server to use static IP. I will use as 172.20.22.74 for the server and 172.20.22.150 for administration workstation.

<2>: Configure CUPS

Default configuration file located at /etc/cups/cupsd.conf.in this file you need to configure the following sections to make it work.

First, check the encryption setting and change

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

to

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

Then we need to tell it to listen for the server change

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

to

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

We need it to be visible to the entire network

# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow @LOCAL

what machines that may access the server change

# Restrict access to the server...
<Location/>
Order allow,deny
Allow localhost
 </Location>

to

# Restrict access to the server...
<Location/>
Order allow,deny
Allow localhost
Allow 172.20.22.*
</Location>

And the same for the configuration files change

# Restrict access to configuration files...
<Location /admin/conf>
AuthType Basic
Require user @SYSTEM
Order allow,deny
Allow localhost
</Location>

to

# Restrict access to configuration files...
<Location /admin/conf>
AuthType Basic
Require user @SYSTEM
Order allow,deny
Allow localhost
Allow 172.20.22.150
</Location>

Other configuration i left default one so need to change anything.

Now you need to restart CUPS using the following command

#/etc/init.d/cupsys restart

You should now be able to connect to the CUPS web interface from the administrator workstation (IP 172.20.22.150 in this example) by pointing your web browser at http://172.20.22.74:631/ once it opens you should see the following screen

If you got the correct drivers installed and your printer is connected to the server, Now you need to add your printer under the "Administration" tab.Setup your printer and finish the setup and verify that it works by printing the CUPS test page.

<3> Setting up the CUPS clients

The CUPS clients are easy to set up and the config is identical on all machines.You need to install the following packages for client

#apt-get install cupsys cupsys-client

Configuring CUPS Client

You need to create /etc/cups/client.confas root

#touch /etc/cups/client.conf

Now you need to edit the /etc/cups/client.conf file

#vi /etc/cups/client.conf

Enter the following information the server IP and the encryption requirement

# Servername
ServerName 172.20.22.74

# Encryption

Encryption IfRequested

Save the file, then restart the client

#/etc/init.d/cupsys restart

Adding Printers

Now you need to add printer in GNOME go to Desktop--->Administration--->Printing

Once it opens you should see the following screen

Select Printer--->Add printer

Once it opens you should see the following screen

In the above screen select Network Printer option,select CUPS Printer and enter the URl and click on Forward

Select your printer manufacturer and model or install printer drivers and click on apply

After finishing the setup you should see the similar to the follwoing screen now your printer is ready for printing.


Incoming search terms:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值