您的位置:首页 > 编程语言 > ASP

raspberry树莓派安装CUPS实现打印服务器共享HP P1007打印机

2016-05-16 10:02 621 查看
虽然很多文章提到了raspberry树莓派如何安装cups实现共享打印机服务,但是我自己试下来发现HP P1007总是无法使用,折腾了很久,终于找到了方法,记录一下。

默认raspberry树莓派已经做好基本设置,IP,SSH之类已经OK。

首先执行更新,我之前就是没执行更新,导致后续操作错误,下载安装时会提示404 找不到文件

sudo apt-get update

更新一番之后安装最新的HPLIP,按照国外的说法,安装好之后应该能解决大部分HP打印机的使用问题。

sudo apt-get install hplip

安装hplip的时候应该已经同步安装好Cups了,如果没有,可以执行下列命令继续安装。

sudo apt-get install cups

安装完hplip之后,配置用户,把pi用加到lpadmin,如果是别的用户,记得更换用户名

sudo usermod -a -G lpadmin pi

下面替换CUPS的配置文件,首先停止服务

sudo service cups stop

备份原有文件

sudo mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.bak

//2015.9.21 update 貌似配置文件无法下载了

//从服务器上下载新的配置文件

//cd /etc/cups/
//sudo wget http://jxeeno.tk/local–files/blog:raspberry-pi:print-server/cupsd.conf
更改配置文件部分参数如下:

# Only listen for connections from the local machine.
#Listen localhost:631

#CHANGED TO LISTEN TO LOCAL LAN
Port 631

# Restrict access to the server…
<Location />
Order allow,deny
Allow @Local
</Location>

# Restrict access to the admin pages…
<Location /admin>
Order allow,deny
Allow @Local
</Location>

# Restrict access to configuration files…
<Location /admin/conf>
AuthType Default
Require user @SYSTEM
Order allow,deny
Allow @Local
</Location>

保存,退出cupsd.conf。
完成,现在可以启动服务了

sudo service cups start

下一步设置打印机,首先将打印机连接到树莓派上,然后在浏览器中输入 https://你的树莓派ip:631 进入配置界面

打开的是一个网站,在上面菜单栏中找到Administrator,会提示你用户名和密码,输入树莓派的用户名和密码即可

登录后,在Printers栏目中点击Add Printer

显示的Local Printers会有你连接上的那台打印机,应该是带有USBxxx之类的,选中它点击continue

在这个界面Name是打印机的名字,以后用来在URL中确定打印机,所以短一些比较好

勾选Sharing,别的不用变,点Continue

下一个界面选择驱动程序,这边的时候记得选择recommended的那个驱动,如果自己有ppd,可以上传打印驱动程序

最后就设置完成了,复制最后一个界面的URL,也就是类似于http://你的树莓派ip:631/printers/打印机名 就可以在其他电脑上添加共享打印机了

如果,如果到这里你添加了树莓派共享的打印机,但是还是没有用的话,请往下看:

按照http://foo2xqx.rkkda.com/的意思,是不建议使用系统自带的foo2zjs driver或者foo2xqx driver的。需要自己根据自己的打印机编译对应的驱动。我的打印机是P1007,应该选择是的foo2xqx driver。接下来就是自己编译了,网站上也有教程。给人家打个广告吧。

foo2xqx: a linux printer driver for XQX stream protocol
e.g. HP LaserJet P1005, P1006, P1007, P1008, P1505, P1505n, P2014, P2014n, M1005 MFP, M1120 MFP
首先下载foo2xqx

wget http://foo2zjs.rkkda.com/foo2zjs.tar.gz

解压缩

$ tar zxf foo2zjs.tar.gz
$ cd foo2zjs

编译和安装

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 P1005     # Get HP LaserJet P1005 firmware file
$ ./getweb P1006     # Get HP LaserJet P1006 firmware file
$ ./getweb P1007     # Get HP LaserJet P1007 firmware file
$ ./getweb P1008     # Get HP LaserJet P1008 firmware file
$ ./getweb P1505     # Get HP LaserJet P1505 firmware file

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

(Optional) Configure hotplug (USB; HP LJ P1005/P1006/P1007/P1008/P1505):
# make install-hotplug      OR      $ sudo make install-hotplug

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

这个时候重新在浏览器中输入 https://你的树莓派ip:631 进入配置界面,删掉原来的打印机,重新配置下打印机,应该就可以使用了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: