These days we want to build a powerful “router” with some access control abilities, where an intuitive way is to use the combination of WifiDog and AuthPuppy on OpenWRT. However, building a LMAP structure is not so easy, especially when we want to do it in x86 platform. Here is a record of our experience.

1. Install OpenWRT on an X86 platform.
Following the instructions here (http://blog.ich8.com/post/4494), which could install a clean installtion of OpenWRT on an x86 platform with version 14.03.

2. Setup LAMP
It has been a while that the default sources on OpenWRT is wrong, that the offical sources has re-archit the directories. Here are some instructions.

2.1 Base part

source: http://downloads.openwrt.org/barrier_breaker/14.07/x86/generic/packages/base/
package list: libexpat libgd libjpeg libncurses libncursesw libopenssl libpcre libpng libpthread libreadline librt iptables-mod-extra iptables-mod-nat-extra

Note after install libpcre, system may not find the proper libpcre.so.0, just make a soft link from libpcre.so.1 in /usr/lib will make it work.

2.2 Lighttpd

source: http://downloads.openwrt.org/barrier_breaker/14.07/x86/generic/packages/packages/
package list: lighttpd lighttpd-mod-access lighttpd-mod-alias lighttpd-mod-cgi lighttpd-mod-fastcgi lighttpd-mod-rewrite

2.3 MySQL

source: http://downloads.openwrt.org/barrier_breaker/14.07/x86/generic/packages/oldpackages/
package list: mysql-server libmysqlclient 

2.4 PHP

source: http://downloads.openwrt.org/barrier_breaker/14.07/x86/generic/packages/oldpackages/
package list: php5 php5-cgi php5-fastcgi php5-mod-apc php5-mod-gd php5-mod-mysql php5-mod-pdo php5-mod-pdo-mysql php5-mod-xml

3. Setup PHP
Modify /etc/php.ini. First make the doc_root empty, and then modify the max-memory size from 8MB to a much larger one.

4. Setup Lighttpd
4.1 Enable some plugins in Lighttpd following this page (http://wiki.openwrt.org/doc/howto/lamp)
4.2 Enbale mod_rewrite which is used in AuthPuppy
4.3 !IMPORTANT Migrate the rewrite rules in AuthPuppy’s .htaccess to url.rewrite part, like below:

url.rewrite-once = ("\.php$" => "$0", "\.html$" => "$0", "^$" => "index.html", "^([^.]+)($|\?.*$)" => "index.php/$1$2")

5. Now you can install authpuppy and wifidog as usual.

It is much easier to record than try to make it.