raspberry樹莓派安裝CUPS實現打印服務器共享HP P1007打印機


雖然很多文章提到了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 進入配置界面,刪掉原來的打印機,重新配置下打印機,應該就可以使用了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM