CentOS 6.2 + CUPS + AirPrint for iOS

混合环境下的打印方法的选择。


So we share our printer via IPP using CUPS. What the heck is IPP? It's just printing over HTTP. Why use IPP versus, say, Windows Printer Sharing? Simple: we've got a mixed environment of Windows XP, Windows 7, OS X 10.6, OS X 10.7, Fedora, Ubuntu, and CentOS workstations. IPP is supported by all of them. Plus, I could get AirPrint to work on it, which means you can add iOS in that list of Operating Systems above.

CUPS

So obviously you need to get CUPS to work first.

yum install cups ghostscript usbutils

So there's the cups package, ghostscript, and usbutils. Since most printers these days are connected via USB, it's always nice to have usbutils installed. Ghostscript is needed since most printers don't really support PostScript so I install it just in case.

So once you've got those installed, you need printer drivers. With so many different printer manufacturers, I leave that up to you, dear reader, as to how to install it. You'll usually need a PPD file. NOTE: if you're printer is supported via foomatic or gutenprint, you can install drivers via:

yum install foomatic gutenprint-foomatic

This should install most drivers available. For example, we have an old Samsung ML-1510 that is supported by foomatic. We do have a newer Samsung ML-1860 that isn't. That required me to download and install Samsung's Unified Printer Driver (ugh). Its install script installed a bunch of .desktop files for every account on our server. So I had to search the entire server and remove all of these useless files. To Samsung: sheesh. This also installed an initscript called smfpd, which is a daemon for parallel port printers. Again, sheesh. You can't disable this from startup via chkconfig. There is a commented out "exit 0" near the start. Uncomment that and the daemon should stop running on startup. Make sure you stop the daemon first as it consumes a bit of CPU and memory. Sheesh. Sorry for the semi-rant.

Anyway, the default CUPS configuration only allows access to localhost. Since I don't worry too much about security, and you can secure it after, I change the following in /etc/cupsd.conf:

I add the following:

ServerAlias *
Port 631

which makes the server listen to any hostname (our server has a CNAME to it calling it 'printer01') on port 631.

Then I make sure to change all "Order deny,allow" to "Order allow,deny" and add an "Allow all" to everything after. This way, I can now remotely access the web GUI at:

http://hostname:631/

Change hostname for whatever you call your print server. If at anytime you're asked for a username and password, use your server's root account. So now that you have access to the web GUI, simply add your printer here.

Now you should be able to start CUPS:

service cups start && chkconfig cups on

Test your printer

So you should be able to add your printer to your workstations. The whole URL to your printer is:

http://hostname:631/printers/PRINTERNAME

or:

ipp://hostname/printers/PRINTERNAME

Special note for Mac users: for the "Queue" setting, make sure you include the "printers" portion. So 'Address' would be the hostname. 'Queue' would be "printers/PRINTERNAME".

Once you've added the printer and selected/installed the correct driver, you should be good to go.

If not, there is a setting called 'LogLevel'. By default it's set as follows:

LogLevel warn

Change it to:

LogLevel debug

and monitor the log files in /var/logs/cups/error_log for any problems.

AirPrint

So now for the fun part: getting AirPrint to work so users can print from their iPhones and iPads. There are some great references online, plus a great script to automatically generate the configuration files needed to get your printer advertised by Avahi.

So, Timothy J. Fontaine of Ataraxia Consulting created a python script that automatically generates a .service file for the printers connected via CUPS. You can read hisblog postabout it. The GitHub repository is available here:

https://github.com/tjfontaine/airprint-generate

Anyway, you can (hopefully) download the file directly here:

https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py

First you'll need to install Avahi:

yum install avahi avahi-compat-libdns_sd

Then you need to install the Python cups module. For CentOS 6.2, this is, strangely, in the "system-config-printer-libs" package. So:

yum install system-config-printer-libs

Then you can run the airprint-generate.py script. Copy the generated .service files into /etc/avahi/services. Then you can start the service:

service avahi-daemon start && chkconfig avahi-daemon on

I had some trouble with printers not being advertised. Since my local network is on br1 instead of eth1 (a KVM thing), I had to add the following to /etc/avahi-daemon.conf:

allow-interfaces=br1

If you had to add that, restart avahi-daemon.

And that's it. Printers should start showing up on your iOS devices.










本文转自 h2appy  51CTO博客,原文链接:http://blog.51cto.com/h2appy/1611391,如需转载请自行联系原作者
如果你有台iPhone手机, 或者苹果iPad平板电脑,那么你可以很方便得利用苹果iOS系统内置AirPrint功能WiFi无线打印照片,Word,PDF等各种文件到你的Air Printer打印机,但有个前提是你的打印机必须支持苹果Air Print功能,即AirPrint-Enable Printer,对于普通打印机而言,有什么办法可以轻松享受到WiFi自由打印这一功能呢? 目前惠普HP,兄弟Brother,佳能Canon等打印机厂商都陆续给打印机内置增加了AirPrint功能,对于普通打印机,包括无WiFi功能的网络打印机,普通USB打印机而言,我们通过Windows电脑网络打印机分享功能可以实现WiFi打印。 由于iOS系统的限制,iPhone, iPad无法和我们常用的Windows系统方便的进行数据交换,iOS设备甚至没有打印机接口,让很多用户认为iPhone,iPad并不能实现文件的打印。但是通过苹果iOS系统提供的AirPrint无线打印功能,可以轻松实现无线打印,更加自由,方便。 AirPrint打印不用连接USB线缆,是名符其实的"无线打印"。iPad能自动在你的WLAN网络中找到支持AirPrint的打印机,并与其相连。无论你是在房间的另一端,或是建筑的另一边,都可以在需要的时候进行打印。整个过程极为简便、快速,在你读完这句话的片刻,这一页就从iPad打印出来了。 简单介绍一下通过Air Printer by Feiphone软件,如何使用普通打印机实现AirPrint功能的方法步骤,而在Mac系统中同样可以实现。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值