Sunday, 29 July 2012 09:19

Openwrt + PHP on TP-Link TL-WR1043ND Router Featured

TP-LINK TL-WR1043ND Wireless Router TP-LINK TL-WR1043ND Wireless Router

This tutorial show you how to install PHP on the TP-Link TL-WR1043ND router.

I assume you already have a working installation of OpenWRT on your router. Click here for more about OpenWRT.

You can refer to my previous post to upgrade firmware to OpenWRT.

After upgraded the router firmware to OpenWRT backfire, SSH to the router. For Microsoft Windows, I always use PuTTY. You can download PuTTY from

Install PHP5

opkg update
opkg install libsqlite3
opkg install php5-fastcgi
# you may need to install php5-mod-session if session authentication require
opkg install php5-mod-session

Screen shot for installing PHP:


You might want to modify the /etc/php.ini. For example to change the time zone:

  1. Find ;date.timezone=
  2. remove the leading semicolon
  3. change it to date.timezone = "Asia/Kuala_Lumpur"

see for more about time zone.



Verify PHP is installing correctly

After that, test php installation by running:

php-cgi -v

You should see the version info and no warning/error message as shown in figure below.



Install lighttpd web server

opkg install lighttpd
opkg install lighttpd-mod-fastcgi
opkg install lighttpd-mod-simple-vhost

Screen shot for installing lighttp:



Modify lighttpd configuration file

Edit the /etc/lighttpd/lighttpd.conf file. The module mod_fastcgi must be enable. I prefer to use  WinSCP to edit the configuration file.


Include index.php to the index-file.names

index-file.names = ( "index.php", "index.html", "default.html", "index.htm", "default.htm" )


Lighttpd is start at port 80 by default, it is conflict with Luci web server. So we need to change it to port 81.

## bind to port (default: 80)
server.port = 81


The following settings is very imortant. Configure wrong bin-path will cause the PHP not running.

Save the configuration file and reboot the router.


Starting lighttpd and PHP

  1. Login to OpenWrt.
  2. Click on System & Select Statup.

Figure below shows how to start lighttpd and PHP.

OpenWrt Startup


 Upload PHP code to Router

Save the following code to phpinfo.php:

<?php// Show all information, defaults to INFO_ALLphpinfo();// Show just the module information.// phpinfo(8) yields identical results.phpinfo(INFO_MODULES);?>


There are many way to upload file to router, I prefer to use WinSCP. The phpinfo.php file is uploaded to the www folder of router as shown in figure below.

Use WinSCP to upload file from computer to router


Run the PHP file

  • Open Internet Explorer
  • Enter (Router default IP)

The screen should show the PHP information.








Read 57626 times Last modified on Sunday, 12 June 2016 11:02
Back to Top