This tutorial show you how to install PHP on the TP-Link TL-WR1043ND router.
You can refer to my previous post http://ediy.com.my/index.php/blog/item/2-openwrt-on-tp-link-tl-wr1043nd-router to upgrade firmware to OpenWRT.
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: http://www.divshare.com/download/18063621-528
You might want to modify the /etc/php.ini. For example to change the time zone:
see http://www.php.net/manual/en/timezones.php 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: http://www.divshare.com/download/18063882-b1d
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
Figure below shows how to start lighttpd and PHP.
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.
Run the PHP file
The screen should show the PHP information.