树莓派+打印机=局域网打印机,电脑手机平板无需安装任何软件驱动即可使用打印机(填坑记录)

因为需要使用打印机的地方非常多,我专门买了一个打印机佳能Cannon MG3680,按照网上的教程配置想打造一个局域网打印机,但是过程却极其艰辛,所以今天来说说树莓派安装以及配置打印机的那些坑,同时我还录了个视频,大家可以看一下。
以防权限不够,转为root

sudo -i

更新软件,保持最新的状态

sudo apt-get update
sudo apt-get upgrade

安装CUPS及相关依赖

sudo apt-get install cups cups-pdf cups-bsd

将pi用户添加到打印机中

sudo usermod -a -G lpadmin pi
sudo systemctl restart cups

允许所有流量访问CUPS,注意的是这步可以不用做,记得重启,因为可以通过CUPS的图形界面配置,具体可观看视频配置。

sudo cupsctl --remote-any

安装SAMBA,如果不要NAS也可不使用,如果安装的话,设备就使用\\ip访问就可以直接安装打印机,不安装SAMBA的话在设置-打印机-搜索处即可安装

sudo apt-get install samba

修改SAMBA配置文件

sudo nano /etc/samba/smb.conf

把下面的代码加在最后面,如果SAMBA配置文件中有,对比着改就行

# CUPS printing.  
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = yes
read only = yes
create mask = 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 = no
guest ok = no

重启SAMBA

sudo systemctl restart smbd

现在说说里面的几个注意点:1、在网页端ip:631,如果树莓派能直接识别为网络打印机,最好选用网络打印机,驱动选择IPP everythingTM的,如果没有再选择Local Printers,2、选择Local Printers的话,如果出现有驱动,但无法打印,说明驱动不行,可以来回换,注意要更换名字,因为不更换的话,还是原来的驱动和PPD文件,如果再不行就需要安装新驱动或者换个PPD文件,这个时候请看后面的建议,3、如果以上都不行,请前往相应的打印机厂商的官网下载驱动,选择linux arm的,下载后执行下面的命令安装官方的驱动(记得改路径),一次不成功就安装多次,并且命名最好不好重复,其他细节请看视频。

bash /mnt/data/raspberry/cnijfilter2-6.30-1-deb/install.sh

如果看了视频以及这上面都没有问题,那么配置一下cups文件,这可能有问题

sudo nano /etc/cups/cupsd.conf

配置内容如下

LogLevel warn
PageLogFormat
MaxLogSize 0
ErrorPolicy retry-job
Port 631
Listen /run/cups/cups.sock
Browsing On
BrowseLocalProtocols dnssd
DefaultAuthType Basic
WebInterface Yes
<Location />
  Order allow,deny
  Allow all
</Location>
<Location /admin>
</Location>
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
</Location>
<Location /admin/log>
  AuthType Default
  Require user @SYSTEM
</Location>
<Policy default>
  JobPrivateAccess default
  JobPrivateValues default
  SubscriptionPrivateAccess default
  SubscriptionPrivateValues default
  <Limit Create-Job Print-Job Print-URI Validate-Job>
    Order deny,allow
  </Limit>
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscr>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit CUPS-Add-Modify-Printer CUPS-Delete-Printer CUPS-Add-Modify-Class CUPS-Delete-Class CUPS-Set-Default CUPS-Get-Devices>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Pri>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <Limit CUPS-Authenticate-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit All>
    Order deny,allow
  </Limit>
</Policy>
<Policy authenticated>
  JobPrivateAccess default
  JobPrivateValues default
  SubscriptionPrivateAccess default
  SubscriptionPrivateValues default
  <Limit Create-Job Print-Job Print-URI Validate-Job>
    AuthType Default
    Order deny,allow
  </Limit>
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscr>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <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>
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Pri>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <Limit Cancel-Job CUPS-Authenticate-Job>
    AuthType Default
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit All>
    Order deny,allow
  </Limit>
</Policy>
<Policy kerberos>
  JobPrivateAccess default
  JobPrivateValues default
  SubscriptionPrivateAccess default
  SubscriptionPrivateValues default
  <Limit Create-Job Print-Job Print-URI Validate-Job>
    AuthType Negotiate
    Order deny,allow
  </Limit>
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscr>
    AuthType Negotiate
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <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>
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Pri>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
  <Limit Cancel-Job CUPS-Authenticate-Job>
    AuthType Negotiate
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
  <Limit All>
    Order deny,allow
  </Limit>
</Policy>
PreserveJobFiles Yes

Windows如何连接上局域网打印机,请看下面的文章

电脑手机平板无需安装任何软件驱动即可使用打印机

手机如何连接上局域网打印机,请看下面的文章

手机无需任何软件即可连接打印机

Avatar photo

请叫我行长

人送外号行长,一个很爱折腾的医学生,总喜欢鼓捣东西,很喜欢数码产品和折腾服务器,然后一直在找一个志同道合又爱打游戏、爱折腾的御姐。你懂的!

相关推荐

暂无评论

发表评论