Rockylinux8配置CUPS打印服务,并支持Bonjour, IPP, SMB, AirPrint打印
使用一台老笔记本安装rockylinux8,连接HP LaserJet Pro P1108,安装配置CUPS打印服务,并使老打印机支持Bonjour, IPP, SMB, AirPrint。
Bonjour:Bonjour使用mDNS/DNS-SD允许计算机在本地网络上查找服务,由Avahi实现
IPP:IPP是互联网打印协议,由CUPS实现
SMB:用于与Windows客户端共享文件和打印机,由Samba实现
AirPrint:允许iPhone、iPad和macOS客户端通过Wi-Fi进行打印,由Avahi实现
初始配置
setenforce 0 && sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config hostnamectl --static set-hostname printer && su dnf update -y
安装配置CUPS
dnf install cups -y systemctl start cups && systemctl enable cups && systemctl status cups systemctl start cups-browsed && systemctl enable cups-browsed && systemctl status cups-browsed firewall-cmd --permanent --add-port=631/tcp firewall-cmd --permanent --add-port=5353/udp systemctl reload firewalld && firewall-cmd --list-all
配置CUPS
cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf_backup vi /etc/cups/cupsd.conf 将Listen localhost:631改为Listen 0.0.0.0:631 找到Restrict access to the server、Restrict access to the admin pages、Restrict access to configuration files,在Order allow,deny下面添加Allow @LOCAL 保存后执行systemctl restart cups
局域网中浏览器可使用http://ip:631打开管理页面
在线安装HP打印机驱动和插件
dnf install hplip gutenprint-cups -y hp-plugin #离线驱动下载地址https://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/
hp-setup -i
此时应该有测试页打印出来
#后期再打印测试可用以下命令 echo "hp test print" > file.txt lp file.txt
使用Bonjour IPP协议共享打印机
dnf install epel-release -y dnf install avahi nss-mdns cups-ipptool -y systemctl start avahi-daemon && systemctl enable avahi-daemon && systemctl status avahi-daemon #Bonjour Print Services for Windows下载地址https://support.apple.com/kb/DL999?locale=en_US
安装配置Samba
dnf install samba -y systemctl start smb nmb && systemctl enable smb nmb && systemctl status smb nmb firewall-cmd --permanent --add-service=samba systemctl reload firewalld cp /etc/samba/smb.conf /etc/samba/smb.conf_backup mkdir -p /usr/share/samba/printer_drivers/ vi /etc/samba/smb.conf 改为 [global] workgroup = SAMBA security = user map to guest = Bad User passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw rpc_server:spoolss = external rpc_daemon:spoolssd = fork spoolss: architecture = Windows x64 [homes] comment = Home Directories valid users = %S, %D%w%S browseable = No read only = No inherit acls = Yes [printers] comment = All Printers path = /var/tmp printable = Yes create mask = 0600 browseable = Yes guest ok = Yes [print$] comment = Printer Drivers Storage path = /usr/share/samba/printer_drivers/ #write list = @printadmin root #force group = @printadmin create mask = 0664 directory mask = 0775 browseable = Yes read only = Yes guest ok = Yes
#旧版本samba实现匿名登陆security = share即可,新版本security = user且map to guest = Bad User才可以 smbcontrol all reload-config && systemctl restart smb nmb
如果本机安装过HP打印机驱动,打开C:\Windows\System32\spool\drivers目录
将打印机驱动上传至samba共享目录
AirPrint打印支持
wget https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py chmod +x airprint-generate.py dnf install gcc python3-devel cups-devel redhat-rpm-config system-config-printer-libs -y echo "image/urf application/vnd.cups-postscript 66 pdftops" > /usr/share/cups/mime/local.convs echo "image/urf urf (0,UNIRAST)" > /usr/share/cups/mime/airprint.types echo "image/urf application/pdf 100 pdftoraster" > /usr/share/cups/mime/airprint.convs pip3 install cups pycups
脚本对python3.6.X支持有bug,直接运行会报错TypeError: write() argument must be str, not bytes
vi airprint-generate.py找到223行,将f = open(fname, 'w')改为f = open(fname, 'wb')
./airprint-generate.py -d /etc/avahi/services/ ls /etc/avahi/services/ systemctl restart avahi-daemon && systemctl status avahi-daemon
测试airprint
本站所有文章均可随意转载,转载时请保留原文链接及作者。