树莓使用CUPS服务搭建打印机服务器

树莓使用CUPS服务配置打印机服务

安装各项软件和进行配置
在树莓派的终端中输入一下代码

sudo su //获取用户权限

apt get update //获取更新状态

apt-get install hplip //安装驱动

apt-get install cups //等待连接CUPS服务器

sudo usermod -a -G lpadmin pi 将用户添加到Ipadmin,pi代表用户名

sudo service cups stop //关闭cups的相关服务

改写配置文件
cd /etc/cups
nano 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>

如果上一段代码无法访问CUPS服务器 请更改为下一段代码

#
# "$Id: cupsd.conf.in 7199 2008-01-08 00:16:30Z mike $"
#
#   Sample configuration file for the Common UNIX Printing System (CUPS)
#   scheduler.  See "man cupsd.conf" for a complete description of this
#   file.
#
 
# Log general information in error_log - change "info" to "debug" for
# troubleshooting...
LogLevel info
 
# Administrator user group...
SystemGroup lpadmin
 
 
# Only listen for connections from the local machine.
Listen *:631
Listen /var/run/cups/cups.sock
 
# Show shared printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseAllow all
 
# Default authentication type, when authentication is required...
DefaultAuthType Basic
 
# Restrict access to the server...
<Location />
  Order allow,deny
  Allow all
</Location>
 
# Restrict access to the admin pages...
<Location /admin>
  # Allow remote administration...
  Order allow,deny
  Allow all
</Location>
 
# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  # Allow remote access to the configuration files...
  Order allow,deny
  Allow all
</Location>
 
# Set the default printer/job policies...
<Policy default>
  # Job-related operations must be done by the owner or an administrator...
  <Limit Send-Document Send-URI Hold-Job Release-Job Restart-Job Purge-Jobs Set-Job-Attributes Create-Job-Subscription Renew-Subscription Cancel-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job CUPS-Move-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
 
  # All administration operations require an administrator to authenticate...
  <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>
 
  # All printer operations require a printer operator to authenticate...
  <Limit Pause-Printer Resume-Printer Enable-Printer Disable-Printer Pause-Printer-After-Current-Job Hold-New-Jobs Release-Held-New-Jobs Deactivate-Printer Activate-Printer Restart-Printer Shutdown-Printer Startup-Printer Promote-Job Schedule-Job-After CUPS-Accept-Jobs CUPS-Reject-Jobs>
    AuthType Default
    Require user @SYSTEM
    Order deny,allow
  </Limit>
 
  # Only the owner or an administrator can cancel or authenticate a job...
  <Limit Cancel-Job CUPS-Authenticate-Job>
    Require user @OWNER @SYSTEM
    Order deny,allow
  </Limit>
 
  <Limit All>
    Order deny,allow
  </Limit>
</Policy>
 
#
# End of "$Id: cupsd.conf.in 7199 2008-01-08 00:16:30Z mike $".
#
  • 改写完后记得ctrl+O进行写入保存,回车后ctrl+X退出
    修改完后重新启动cups服务
    sudo service cups restart

  • 在树莓派浏览器中输入
    http://树莓派的IP:631

访问时可能会出现网页不安全警告,一般无需理会,继续访问

提示你输入用户和密码时则直接使用树莓派管理员用户登录即可。

登录后选择Administartion

子选项中有Add Printer选择,点进去后就能看见USB连接到树莓派的打印机,注意勾选打印机的序号,下面的网络协议可以不勾选。

进入配置名字和用户组的界面时需要勾选最下方的Share This Printer。点击continue

在Model中勾选打印机需要的对应驱动,点击Add Printer

在同一局域网内,window能够直接检索到已配置的打印机

在设备-打印机和扫描仪-添加设备-添加已连接树莓派的打印机

如果无法刷新出打印机则参考下述步骤

填入http://树莓派IP:631/printers/CUP中配置的打印机名称

在这里插入图片描述

等待驱动安装完成后即可使用内网连接直接打印文件

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值