专业版 cups 打印服务器

1.安装CUPS

sudo apt-get update

sudo apt-get install cups --安装CUPS

2.调整配置文件

nano不要安,用vim /etc/cups/cupsd.conf

调整内容见下面第一个网页
3.service cups restart
4.web页面配置访问地址是:ip地址:631  4之后不成功,页面里没找到驱动(hp1020),就是驱动没安, 找了离线ppd文件,测试页也打不出来。 折腾之路(docker也要安): 1.apt install pyqt5-dev-tools 2.安装 hplip:sudo apt-get install hplip  安装时有 Y 按 Y hplip (这时候页面里有1020驱动了,可以安装了, 但是测试页还没反应, 还需要安装hp-plugin3.sudo hp-plugin 选的d 在线下载很慢,最后完成了。离线安装没试过方法:还是得先运行sudo hp-plugin ,看后面的版本号
wget https://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/hplip-3.18.12-plugin.run
wget https://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/hplip-3.18.12-plugin.run.asc

下载好两个文件后,就可以本地安装了,默认下载到root里。

一样的 执行下面命令:

sudo hp-plugin

弹出下面三个选项后:

Option Description
---------- --------------------------------------------------
d Download plug-in from HP (recommended)
p Specify a path to the plug-in (advanced)
q Quit hp-plugin (skip installation)

Enter option (d=download*, p=specify path, q=quit) ?
选择p,然后基本上回车或者输入yes一路到底就可以了。直到最后显示安装成功,所有软件上的准备工作也就完了了

5.开机自动启动

sudo systemctl enable cups

 

6.内网穿透

接下来要配置的是CUPS参数:

vi /etc/cups/cupsd.conf
在<location /> 之上,插入以下两行代码

WebInterface Yes

ServerAlias *
WebInterface Yes (表示允许从网上打印 )

ServerAlias * (*表示所有域名)也可以只填允许访问的域名多个域名用空格隔开。

配置完成后按Esc 输入:x 保存并退出

重启cups即可

玩客云刷完海纳思(hinas)安装cups并配置网络打印机_海纳思安装cups打印服务器-CSDN博客 (2025_3_2 19:39:53)

专业版 cups 打印服务器 | 海纳思系统 (2025_3_2 19:42:36)

打印机无线改造 (2025_3_9 20:59:57)

电视盒子安装CUPS共享惠普1020为无线网络打印机【新版】_cups hp1020-CSDN博客 (2025_3_9 21:06:22)

再写一下怎么卸载 cups
查看 CUPS 服务是否正在运行:
打开终端,运行以下命令来检查 CUPS 服务是否正在运行:
sudo systemctl status cups
如果结果显示 CUPS 服务处于「active」状态,则表示 CUPS 正在运行。如果不是活动状态,你可以跳过下面的停止服务步骤。
停止 CUPS 服务:
如果 CUPS 服务正在运行,你需要停止它。在终端中运行以下命令:
sudo systemctl stop cups
卸载 CUPS 软件包:
在终端中运行以下命令以卸载 CUPS 相关的软件包:
sudo apt remove cups cups-client
如果你是在其他 Linux 发行版上使用,可以使用相应的包管理器来卸载 CUPS 软件包。
删除 CUPS 配置文件和数据:
在终端中运行以下命令以删除 CUPS 的配置文件和数据:
sudo rm -r /etc/cups/ sudo rm -r /var/spool/cups/
移除 CUPS 用户和组:CUPS 安装过程中创建了一个名为「cups」的用户和组。如果你不再使用 CUPS,你可以删除这些用户和组。在终端中运行以下命令:
sudo userdel cups sudo groupdel cups
清理残留文件:
为了确保彻底卸载,你可以在终端中运行以下命令来清理任何残留文件:
sudo apt autoremove sudo apt autoclean
这将自动删除不再需要的依赖项和缓存文件。
检查卸载是否成功:
你可以通过运行以下命令来检查 CUPS 是否被彻底卸载:
sudo systemctl status cups
如果显示「CUPS.service could not be found.」,则表示 CUPS 已成功卸载。
这样,你就完成了在 Linux 上卸载 CUPS 的过程。请注意,这些步骤可能会因为不同的 Linux 发行版而有所差异,但是大致上是类似的。在执行这些步骤之前,请确保你有管理员权限。
删除 HPLIP
sudo apt remove hplip

 

docker pull docker.1ms.run/ydkn/cups

docker run -d \
–name cups \
-p 631:631 \
-e CUPS_ADMIN_USER=admin \
-e CUPS_ADMIN_PASSWORD=admin \
–restart unless-stopped \
docker.1ms.run/ydkn/cups:latest

 

 

 

 

附cups.config:

#
# Configuration file for the CUPS scheduler. See “man cupsd.conf” for a
# complete description of this file.
#

# Log general information in error_log – change “warn” to “debug”
# for troubleshooting…
LogLevel warn
PageLogFormat

# Deactivate CUPS’ internal logrotating, as we provide a better one, especially
# LogLevel debug2 gets usable now
MaxLogSize 0

# Only listen for connections from the local machine.
Listen 0.0.0.0:631
Listen /run/cups/cups.sock

# Show shared printers on the local network.
Browsing On
BrowseLocalProtocols dnssd

# Default authentication type, when authentication is required…
DefaultAuthType Basic

# Web interface setting…
WebInterface Yes

ServerAlias *

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

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

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

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

# Set the default printer/job policies…
<Policy default>
# Job/subscription privacy…
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default

# Job-related operations must be done by the owner or an administrator…
<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-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job>
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>

<Limit CUPS-Get-Document>
AuthType Default
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 CUPS-Get-Devices>
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 Cancel-Jobs 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>

# Set the authenticated printer/job policies…
<Policy authenticated>
# Job/subscription privacy…
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default

# Job-related operations must be done by the owner or an administrator…
<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-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
AuthType Default
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 Cancel-Jobs 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>
AuthType Default
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>

<Limit All>
Order deny,allow
</Limit>
</Policy>

# Set the kerberized printer/job policies…
<Policy kerberos>
# Job/subscription privacy…
JobPrivateAccess default
JobPrivateValues default
SubscriptionPrivateAccess default
SubscriptionPrivateValues default

# Job-related operations must be done by the owner or an administrator…
<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-Subscription Get-Notifications Reprocess-Job Cancel-Current-Job Suspend-Current-Job Resume-Job Cancel-My-Jobs Close-Job CUPS-Move-Job CUPS-Get-Document>
AuthType Negotiate
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 Cancel-Jobs 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>
AuthType Negotiate
Require user @OWNER @SYSTEM
Order deny,allow
</Limit>

<Limit All>
Order deny,allow
</Limit>
</Policy>

发表评论

邮箱地址不会被公开。 必填项已用*标注