Files
S905L3A/CUPS打印服务配置交接文档.md
yuyx 8720c65416 完善CUPS远程打印配置 + 添加交接文档
setup_cups.sh:
- 添加 ServerAlias * 支持任意主机名访问
- 添加 DefaultEncryption Never 禁用强制加密
- 添加 /printers 和 /printers/* 位置块允许远程打印
- 修改 Policy 允许匿名打印任务

新增文档:
- CUPS打印服务配置交接文档.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 22:02:39 +08:00

231 lines
4.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# CUPS 打印服务配置交接文档
## 概述
本文档记录了 CUPS 打印服务的完整配置过程,包括一键安装脚本、中文汉化、远程访问配置等。
---
## 一、一键安装
### Gitee 仓库
```
https://gitee.com/yu-yon/S905L3A.git
```
### 一键安装命令
```bash
# 方式一curl
curl -fsSL https://gitee.com/yu-yon/S905L3A/raw/master/setup_cups.sh | bash
# 方式二wget
wget -qO- https://gitee.com/yu-yon/S905L3A/raw/master/setup_cups.sh | bash
```
### 脚本功能
- 自动检测系统架构x86_64/ARM64/ARMhf
- 可选更换国内镜像源(清华大学)
- 安装 CUPS + AvahiAirPrint 支持)
- 多种打印机驱动可选(通用/HP/爱普生/兄弟/奔图)
- 自动配置远程访问权限
- 安装中文界面模板
---
## 二、已安装的服务
| 服务 | 端口 | 用途 |
|------|------|------|
| CUPS | 631 | 打印服务/Web管理界面 |
| Avahi | 5353 | mDNS/AirPrint 自动发现 |
| Samba | 445/139 | Windows SMB 打印共享 |
| LPR (xinetd) | 515 | LPR 打印协议 |
---
## 三、客户端连接方式
### 局域网环境(推荐)
| 客户端 | 连接方式 |
|--------|----------|
| **macOS/iOS** | 自动发现AirPrint无需配置 |
| **Android** | 安装 Mopria Print Service自动发现 |
| **Linux** | 自动发现或手动添加 `ipp://IP:631/printers/打印机名` |
| **Windows** | `\\局域网IP\打印机名` 或 IPP 协议 |
### 公网环境
公网环境较为复杂,可能遇到以下问题:
- Windows IPP 强制使用 HTTPS自签名证书不受信任
- SMB 445 端口可能被 ISP 阻止
- 需要在云服务器安全组开放相应端口
**公网可用方案:**
1. **LPR 协议(推荐)**
- 端口515
- 队列名:打印机名(如 PDF
- Windows 添加方式TCP/IP 打印机 → 自定义 → LPR 协议
2. **IPP + 证书信任**
- 需要将服务器证书导入 Windows 受信任的根证书
---
## 四、CUPS 管理界面
### 访问地址
```
http://服务器IP:631
https://服务器IP:631
```
### 登录凭据
- 用户名root
- 密码SSH 登录密码
### 常用操作
- 添加打印机Administration → Add Printer
- 管理打印队列Printers → 选择打印机
- 查看任务Jobs
---
## 五、重要配置文件
| 文件路径 | 说明 |
|----------|------|
| `/etc/cups/cupsd.conf` | CUPS 主配置文件 |
| `/etc/cups/printers.conf` | 打印机配置 |
| `/etc/cups/ssl/` | SSL 证书目录 |
| `/etc/samba/smb.conf` | Samba 配置SMB 打印共享) |
| `/etc/xinetd.d/cups-lpd` | LPR 服务配置 |
| `/usr/share/cups/templates-zh_CN/` | 中文界面模板 |
---
## 六、关键配置说明
### cupsd.conf 关键配置
```apache
# 监听所有网络接口
Listen 0.0.0.0:631
# 允许任何主机名访问
ServerAlias *
# 禁用强制加密(允许 HTTP
DefaultEncryption Never
# 中文界面
DefaultLanguage zh
# 允许远程访问
<Location />
Order allow,deny
Allow all
</Location>
# 允许远程打印
<Location /printers>
Order allow,deny
Allow all
</Location>
```
### Samba 打印配置
```ini
[global]
printing = cups
printcap name = cups
load printers = yes
[printers]
comment = All Printers
path = /var/spool/samba
printable = yes
guest ok = yes
```
---
## 七、常用命令
```bash
# 查看打印机列表
lpstat -p -d
# 重启 CUPS
systemctl restart cups
# 查看 CUPS 日志
tail -f /var/log/cups/error_log
# 重启 Samba
systemctl restart smbd nmbd
# 重启 LPR 服务
systemctl restart xinetd
# 检查端口监听
ss -tlnp | grep -E "631|445|515"
```
---
## 八、故障排除
### 问题1Windows 无法连接 IPP 打印机
**原因**Windows IPP 客户端强制使用 HTTPS自签名证书不受信任
**解决**:使用 LPR 协议或 SMB 协议代替
### 问题2SMB 连接失败0x80070035
**原因**445 端口被防火墙/ISP 阻止
**解决**
- 检查云服务器安全组是否开放 445 端口
- 局域网内通常无此问题
### 问题3打印任务卡住
**解决**
```bash
# 取消所有任务
cancel -a
# 重启 CUPS
systemctl restart cups
```
### 问题4中文界面不生效
**解决**
```bash
# 确保中文模板已安装
ls /usr/share/cups/templates-zh_CN/
# 检查 locale 设置
locale -a | grep zh_CN
```
---
## 九、文件清单
```
/root/yuyx/B863AV3.2M刷Armbian教程/
├── setup_cups.sh # 一键安装脚本
├── cups-templates-zh_CN/ # 中文界面模板65个文件
├── 刷机教程.md # Armbian 刷机教程
└── CUPS打印服务配置交接文档.md # 本文档
```
---
## 十、待测试项目
- [ ] 局域网 Windows SMB 连接
- [ ] 局域网 macOS/iOS AirPrint 自动发现
- [ ] 局域网 Android Mopria 打印
- [ ] 真实 USB 打印机连接测试
---
**文档创建时间**2025-11-30
**配置环境**Ubuntu 22.04 / CUPS 2.4