Aug 272013



ALL of the following commands will be run as root. If you are not root already, you can become root by entering “sudo su” as user pi.

Install packages

aptitude update
aptitude install avahi-daemon cups cups-pdf python-cups
  • This will update your package list, and install the packages we need
  • avahi-daemon is a free zeroconf implementation (open source Bonjour replacement)
  • CUPS = Common Unix Printing System – manages the printers for you

This command will take a while, especially after [ ok ] Starting Common Unix Printing System: cupsd. Please be patient here.

Edit /etc/cups/cupsd.conf

nano /etc/cups/cupsd.conf

Comment out the line just below “# Only listen for connections from the local machine.” with an #, and add some new lines, like this:

# Only listen for connections from the local machine.
#Listen localhost:631
Port 631
# Restrict access to the server...
<Location />
  Order allow,deny
  Allow @Local
# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
  Allow @Local
# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @Local

Leave the other lines as they are.

  • This will allow access to the CUPS web interface from other machines than your Raspberry Pi itself (on the local network)
  • We advise you to change the default “raspberry” password for the user “pi” just in case …
  • You can change the port from 631 to something else, but be sure to replace it in the instructions below!

Restart the CUPS service

service cups restart
  • This will restart the CUPS service and reload it’s configuration files

Add the user pi to the lpadmin group

This is necessary to allow you to administrate the printers through the web interface as user pi, later on:

adduser pi lpadmin

AirPrint will have to be enabled after you have added the printers.


Add printer(s)

CUPS actually has a very nice web-interface. It apparently has been purchased by Apple in 2007, and is being supported by that huge company and the original developer, Michael Sweet. Maybe that is one reason why it really works quite effortlessly. But, let’s begin:

Open your favorite browser, and enter “https://” + your Raspberry Pi’s IP address + “:” + the port (631 as default).

For example:

CUPS Admin interface

Your browser will most definitely warn you about a security certificate problem. Please ignore it, and continue (or do you sign certificates for your local machines?)


Hint: CUPS will show up to you in the language your browser indicates to it. Even the directive “DefaultLanguage en” in the configuration file will NOT change that. In other words, to change the language of the CUPS web interface, change your browser default language setting.

Modify CUPS Settings

Click on the Administration Tab, and check “Share printers connected to this system”. Click on “Change Settings”.


At this point you will probably be asked to enter your credentials. If you have added the user pi to the printer management group lpadmin, as per instructions above, you can enter it’s credentials now:


The CUPS server is being restarted.

Connect Printer to CUPS

You can add network printers, or USB printers to CUPS.

Before continuing with the instructions, please ensure that your printer is connected to the network or via USB to the Raspberry Pi , and powered on. You do not need to restart your Raspberry – you can simply plug in your printer right now.

Add a new printer to CUPS

If you have a USB printer, click on “Find New Printers” on the Administration tab (this is called “Verfügbare Drucker auflisten” in German)


CUPS will take a while – and it should list all printers which it has recognized.


Simply add the printer, in this example my trusty Kyocera FS-3900DN (I will only buy Kyocera Laser printers from now on Winking smile). My DYMO LabelWriter 450 was also recognized “out-of-the-box”.

Now simply follow the dialogues and enter sensible values:




(Note: the connection line in the screenshot will say something like “usb://…” for USB printers).

Select your Make and your Model here. A lot of printers are listed. If you don’t find yours, try to find a PPD file for it on the web: A PPD File is a “PostScript Printer Description”” File – it describes fonts, paper sizes, resolutions and other capabilites that are standard for a particular Postscript printer.

Now you will be presented with a dialogue which will have different default options to set up, according to your printer.

Here’s the one for the Kyocera FS-3900DN, for example:


Please note: these are default options. If, for instance, the paper sizes your printer supports are not listed here (as is the case for my DYMO LabelWriter 450), simply select the next “matching” one, and set it up under Windows / your Mac correctly.

Now your printer is set up, and you can continue:

Print test page

The CUPS menu “Printers” will list the available printers. By clicking on a particular printer, you can administrate it. For instance, you can print a test page from the Maintenance drop down menu:


CUPS will show you the progress of the print job.

Adding network printers to CUPS

If you have a network printer, we recommend to use the “Add Printer” button instead, and setting up the printer manually.


The CUPS manual recommends to use “HP JetDirect” as it is the most reliable protocol. This works with my Kyocera FS-3900DN.


In the next screen, enter your printer’s IP address, followed by the port (i.e. socket:// ). There are options to set up secure (encrypted) printing, but this is beyond the scope of this article.

Now you can continue as described above.

Set up AirPrint

In GitHub, there is a script which creates the AirPrint service. In the German article this one translates and elaborates, it is recommended to put it into /opt/AirPrint.

As user root (sudo su):

mkdir /opt/AirPrint
cd /opt/AirPrint
wget -O --no-check-certificate
chmod +x
./ -d /etc/avahi/services
service cups restart
service avahi-daemon restart

This will:

  • Create a new directory “/opt/AirPrint”, change into it
  • Download the script
  • make it executable
  • execute it, and modify the configuration files in the directory /etc/avahi/services (add an XML description of the new printer service)
  • restart the CUPS and avahi services

If the ./ command yields an error, like “image/urf is not in mime types, [PRINTER_NAME] may not be available on ios6 (see”, please refer to the solution in the German article (there is always Google Translate)

The printers should be available now.


Install printer on Windows

Open “Devices and Printers”. Click “Add a printer”. Select “Add a network, wireless or Bluetooth printer”.


Select “The printer that I want isn’t listed”



Select “Select a shared printer by name”, and enter http:// + Raspberry Pi IP + :631 + /printers/ + your printer’s name (called “Queue Name” in CUPS).

For example:

Again, this could probably be changed for encryption – but is outside the scope of this beginner’s article.

Click “Next”, and continue to install the driver. If you can’t select it from the list, try Windows Update (be patient). If that does not work, try to locate the driver on the vendor’s homepage. I had to do the latter for the DYMO LabelWriter 450.

Remember to set up sensible default settings for your new network printer. These settings will override the settings you set on CUPS – thus you CAN actually print to page formats CUPS does not know yet.


Add printer to Apple Mac

This Apple KB article should help you to set up your printer on your Mac. Unfortunately there’s no Mac here, when we have access to one, we will test it.



Problem solving

Can’t find a network printer

Try to add it manually, by using it’s IP address and the information we have given you in this article. If it still does not work, try changing your printer LAN server settings.

Well, what about SAMBA?

CUPS printers can be shared through SAMBA. This is additional configuration overhead, but may add the possibility for Windows machines to automatically download drivers from the Raspberry Pi. This is beyond the scope of this article.


Jun 172013


wifi_logo (1)In diesem Artikel stelle ich eine Lösung vor, um  das Netzwerk an dem der Raspberry verbunden ist über einen USB WLAN Adapter für andere Computer zur Verfügung zu stellen. Der Raspberry arbeitet dabei als Brücke (bridge), und leitet einfach alle Daten die am WiFi  Adapter ankommen in das LAN weiter.

Das kann bspw. sinnvoll sein, wenn man zwei Netzwerke zu Hause betreiben möchte – ein schnelles für n-fähige Geräte, und ein langsames für b / g Geräte; Eine Isolation der Netzwerke gegeneinander findet aufgrund des bridged Modes in unserer Anleitung nicht statt – die IP Adressen der über WLAN angeschlossenen Computer z..B. werden vom  DHCP-Router vergeben, nicht vom Raspberry.

Ein weiterer Einsatzzweck ist das Einrichten von WLANs in anderen Stockwerken / entfernten Orten (z.B. im Keller?), vor allem wenn man  dem  Raspberry noch weitere Aufgaben angedeihen lassen möchte.

Der Vorteil an der bridged Lösung ist geringerer Prozessor-Overhead für den Raspberry, und geringerer Verwaltungsaufwand (IP Adressen).


Nicht alle USB WLAN Sticks unterstützen den dazu notwendigen AP Modus, bzw. die “nl80211 API”. Wir beschreiben weiter unten, wie Sie Ihren Stick überprüfen können.

cartIn unserem Shop bieten wir den Logilink WL0084B v2.0 an, der als Access Point geeignet ist.

Er basiert auf dem Ralink RT5370 Chipsatz.


Root-Rechte nötig

Die folgenden Kommandos sind alle als root Nutzer auszuführen (sudo su).

Installation der nötigen Pakete
aptitude install hostapd hostap-utils iw bridge-utils
  • hostapd, hostap-utils: WLAN Stick als Access Point nutzen
  • iw: Konfigurations-Programm für Funknetzwerk-Devices
  • bridge-utils: ermöglichen zwei Netzwerke miteinander zu verbinden

iw hilft festzustellen ob Ihr USB-WiFi Stick Access-Point fähig ist. Nicht alle sind es!

iw list

iw list zeigt die vorhandenen Funknetzwerk-Geräte an.

nl80211 not found

Falls hier der Fehler “nl80211 not found” auftaucht, wird eine ältere Version von hostapd benötigt. Weitere Details dazu – bspw. für den TP-Link TL-WN725N WiFi – gibt es auf dieser Seite. Der besagte TP-Link wäre bei lsusb beispielsweise folgendermaßen aufgeführt (v1):

Bus 001 Device 011: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

Sticks die die nl80211 API unterstützen

Wir benutzen im folgenden einen USB-WLAN Stick, der die nl80211 api unterstützt, d.h. dieser Fehler taucht NICHT auf, sondern man erhält mit iw list etwa folgende Ausgabe:

root@andromeda:~# iw list
Wiphy phy9
        Band 1:
( ... )
        Available Antennas: TX 0 RX 0
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * WDS
                 * monitor
                 * mesh point
        software interface modes (can always be added):
                 * AP/VLAN
                 * monitor
        interface combinations are not supported
( ... )        
Device supports HT-IBSS.

Wir nutzen einen Logilink Adapter (Modell WL0084B v2.0), per lsusb wird dessen Chipsatz identifiziert als:

Bus 001 Device 021: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter



Zunächst muss man in der /etc/init.d/hostapd den Pfad zur (noch zu erstellenden) hostapd Konfigurationsdatei einstellen. ( nano /etc/init.d/hostapd ) Finden Sie die Zeile mit DAEMON_CONF, und ergänzen Sie sie wie folgt:


erstellen Sie jetzt die hostapd.conf ( nano /etc/hostapd/hostapd.conf ) und befüllen Sie sie mit dem folgenden Inhalt:

# Basic Config
# Most modern wireless drivers in the kernel need driver=nl80211
# Local configuration...
Kurze Diskussion der Datei /etc/hostapd/hostapd.conf

hostapd.conf ist empfindlich was Leerzeichen hinter den jeweiligen Konfigurationseinstellungen angeht – bitte vermeiden Sie diese daher.

  • driver: nl80211 bei Geräten die die nl80211 API unterstützen. Es sind auch andere (legacy-) APIs verfügbar, siehe hier
  • interface: man kann auch mehrere WiFi Adapter am Raspberry anschließen – der erste heißt wlan0
  • bridge: diese Brücke werden wir gleich noch einrichten
  • hw_mode: Verbindungsmodus. g bedeutet: g + b
    • b bedeutet: nur b
  • SSID: die SSID des Hotspots
  • wpa=3: WPA1 und WPA2 werden enabled – diese sind dem unsicheren WEP vorzuziehen
  • wpa_passphrase: das ist Ihr Netzwerkschlüssel. BITTE ÄNDERN SIE DIESEN!!

Um 802.11 n einzuschalten, muss man einen zusätzlichen Parameter “ieee80211n” auf 1 setzen. z.B. für g & n:

Konfiguration der bridge

Die Bridge sorgt dafür, dass die Netzwerkpakete die die Access Point Clients über diesen senden direkt über den Ethernet Port des Raspberrys weitergeleitet werden. Wir haben die bridge-utils bereits installiert, und müssen nur noch die Einstellungen anpassen.

Editieren Sie die /etc/network/interfaces (nano etc/network/interfaces )

auto lo

iface lo inet loopback
auto br0
iface br0 inet static
        bridge-ports eth0 wlan0

Kurze Diskussion:

  • Die bridge br0  ersetzt Ihr bisheriges eth0 Interface, sie wird daher wie eth0 konfiguriert
    • hier in einer statischen Konfiguration – unser Netzwerk ist 192.168.1.*, der Router
  • bridge-ports eth0 wlan0 ist das “magische Kommando”, was wlan0 mit eth0 verknüpft
  • Das ist alles – keine weiteren Einträge (insbesondere nicht für wlan0)


Nach einem Neustart sollte das System voll funktionsfähig sein. Sie können jetzt Clients mit Hilfe der Zugangsdaten über den Access Point verbinden.

Alternativ können Sie es auch mit folgenden Kommandos ohne Neustart versuchen:

ifdown eth0; ifup br0
service hostapd restart

In unserem Setup ist kein dnsmasq nötig – das wäre erforderlich, falls Sie keine bridge machen wollen, sondern den Clients eigene IP Adressen aus einem anderen Bereich geben wollen, z.B. aus Sicherheitsüberlegungen.

Windows – debugging, etc.

  • um die IP Adresse herauszufinden: unter Powershell: ipconfig /all
  • Es empfiehlt sich, die Funknetzwerkbelegung zu analysieren, um den Durchsatz zu optimieren. Unter Windows gibt es dazu bspw. das Tool InSSIDer. (Scheint kostenlos zu sein).


Dokumentation & weiterführende Links

  • InSSIDer – WiFi Analyse-Tool für Windows (auch mit Windows 8 kompatibel)
May 082013

Ever found yourself manually typing in information from one computer to the next, or saving to a text file on a thumb drive, unplugging it (not forgetting to swear at Microsoft Windows for not letting it go “safe removal problems” …), replugging it into the other computer, etc, etc …

Well there’s Apps like Evernote for situations like these. But you do not always want the full-blown extravaganza of note-taking Evernote provides. What about the good old quick & dirty approach?

There is a solution for that. A PHP based script, which can be run on your local Raspberry server.

Installing nginx

Apache is a very heavyweight / bloated webserver compared to nginx. For our purposes (some light PHP without any .htaccess / mod_rewrite magic) nginx will be quite OK.

Install and start nginx:

aptitude install nginx
service nginx start

Installing PHP and acceleration

We will install PHP-FPM, the Fast CGI PHP daemon. Fast CGI is a good choice (much faster than plain old CGI). Stil we will want some additional acceleration – PHP compiles each time a web page is opened, and pages rarely change. By caching the compilation output we can significantly increase the speed and responsiveness. VERY important on the Pi!

apt-get install php5-fpm
apt-get install php5-xcache
service php5-fpm restart

The default installation of PHP-FPM on the Pi will be configured to use Unix sockets, which again is a good thing as it eliminates TCP overhead.

Configuring nginx

You should now configure nginx and tell it to process .php files through the PHP-FPM daemon.

Edit your /etc/nginx/sites-available/default – it should look something like this after you’re finished:

server {
        listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6

        root /webroot;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.html;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow ::1;
                deny all;

        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #       proxy_pass;

        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/www;

        # pass the PHP scripts to FastCGI server listening on
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #       # With php5-cgi alone:
        #       fastcgi_pass;
        #       # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #location ~ /\.ht {
        #       deny all;

Notable entries in this file are:

  • I have changed the web server root to /webroot
    • obviously you need to create this directory and also change the owner to www-data:www-data
  •  index index.php index.html index.htm; –> use index.php first, if it exists
  •  try_files $uri =404; –> attempt to prevent “zero day exploits”
  • fastcgi_pass unix:/var/run/php5-fpm.sock; –> this tells nginx to use a Unix socket. The path is the default one for php5-fpm on Raspbian

Installing the webnotepad

This could be any other PHP application which does not depend upon a database backend. I’m going to make this real quick and rough:


This is a preview of the web notepad you are about to install.

Konstruktors html5-notepad

Get it from the above link ( we are using version 0.2) – the demo on that page seems to be down.

Unzip it, mv the folder which is extracted to a meaningful name (we chose “notes”). Inside it, create a folder with some random name (there is no entries folder in the ZIP download, just create a new folder).

Edit sync.php and change the DATA_DIR to the random name you entered, and edit user and password name (if you run out of ideas, try pi / raspberry).

Just use it to jot down notes, and transfer text (i.e. Dropbox links ?) between computers.

Most important: the Raspberry Pi is getting more useful by the day!

Optimization WordPress Plugins & Solutions by W3 EDGE