Raspberry Pi를 AirPrint 서버화하고 iPad에서 AirPrint 지원되지 않는 프린터로 인쇄 할 때까지

iPad용의 업무 앱 개발중에서, 인쇄시킬 필요가 있습니다만, 프린터가 AirPrint 비대응이므로 라즈베리 파이를 AirPrint 서버화했습니다.
Mac, WindowsPC를 서버화하면 더 간단하게 할 수 있을 것입니다만, 가능한 한 컴팩트한 구성으로라는 것이었으므로・・・
현재 상태는 유선 Lan에서 DHCP 연결 상태입니다.

Raspbian 설치



Raspbian 다운로드



공식 에서 최근 Raspbian 을 다운로드합니다.
데스크탑 환경은 필요 없기 때문에, LITE쪽으로 했습니다.
zip이라고 1시간 정도 걸릴 것 같았기 때문에, 토렌트로 했습니다만, 이쪽이라면 5분 정도로 끝났습니다.

검증


$ shasum 2016-02-26-raspbian-jessie-lite.zip

출력 결과와 DL원에 게재되어 있는 값을 비교한다.

설치



이름이나 사이즈로부터 판단해 인식되고 있는 디바이스 확인한다.
$ diskutil list

형식
$ diskutil eraseDisk FAT32 RPI /dev/disk2

언마운트
$ diskutil unmountDisk /dev/disk2

쓰기
$ tar zxvf 2016-02-26-raspbian-jessie-lite.zip
$ sudo dd bs=1024m if=2016-02-26-raspbian-jessie-lite.img  of=/dev/rdisk2

시작



전원 찔러서 시작합니다.

모니터, 외장 키보드가 없는 경우



ssh로 연결하기 때문에 모니터는 필요 없지만 IP 주소를 모르기 때문에 Mac을 DHCP 서버에 일시적으로 한다.
Lan 케이블을 라즈베리 파이와 Mac을 연결합니다.
(Macbook pro 13 late 2013이라면 으로 연결된다)
시스템 환경 설정 -> 공유로 설정합니다. (AX88x는 PLANEX 어댑터.)

$ arp -a
? (192.168.2.102) at 0:a0:de:31:48:77 on en0 ifscope [ethernet]
? (192.168.2.255) at (incomplete) on en0 ifscope [ethernet]
? (192.168.3.3) at b8:27:eb:2e:67:66 on bridge100 ifscope [bridge]

255는 다르다. 102도 아마 다르다. 라는 느낌으로 그러한 IP 주소를 찾는다.

ssh로 연결


$ ssh [email protected]

시작 후(user:pi pass:raspberry)


$ sudo raspi-config
  • Expand Filesystem
  • Internationalisation Options
  • Change Locale
  • "en_GB.ISO-8859-15 ISO 8859-15""ko_KR.EUC-KR EUC-KR""ko_KR.UTF-8 UTF-8"
  • 디폴트 「ko_KR.UTF-8」

  • Change Timezone
  • Asia, Tokyo


  • $ sudo shutdown -r now
    

    업데이트, 업그레이드


    sudo apt-get update; sudo apt-get upgrade -y
    sudo shutdown -r now
    

    방화벽 설정



    Port 631은 cups용
    $ sudo apt-get install -y ufw
    $ sudo ufw allow 22
    $ sudo ufw allow 80
    $ sudo ufw allow 8080
    $ sudo ufw allow 631
    

    Apache 설치


    $ sudo apt-get install -y apache2
    

    웹 브라우저에서 http://(라즈베리 파이의 IP 주소)에서 Apache의 동작 확인.

    Vim 설치


    $ sudo apt-get install -y vim
    

    cups, avahi-discover 설치, 설정


    $ sudo apt-get install -y cups cups-pdf python-cups avahi-discover
    $ sudo usermod -aG lpadmin pi
    $ sudo /etc/init.d/cups start
    $ sudo /etc/init.d/avahi-daemon start
    $ sudo vim /etc/cups/cupsd.conf
    
    #Listen localhost:631を下記にする
    Port 631
    
    # Allow @Localを入れる
    # 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>
    
    $ sudo /etc/init.d/cups restart
    

    http://IP 주소:631 방문.
    라즈베리 파이와 프린터를 유선으로 연결하십시오. (OS 기동전에 접속해 두는 것이 좋을지도)

    프린터 및 클래스 추가 > 프린터 추가

    프린터 선택.

    이 프린터를 공유하려면 체크합니다.

    모델을 선택합니다.

    프린터를 추가하고 마지막으로 기본 설정을 지정합니다.

    iPad에서 인쇄.
    AirPrint 지원되지 않는 EPSON PM-G860을 선택할 수 있습니다.


    프린터를 선택할 수 있지만 인쇄가 시작되지 않는 경우



    이것으로 인쇄 할 수 있습니다 ...
    $ sudo /etc/init.d/cups restart
    $ sudo /etc/init.d/avahi-daemon restart
    

    좋은 웹페이지 즐겨찾기