What's new

THTTPD lightweight webserver with PHP

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

davebra

New Around Here
Hi,

I have successfully installed THTTPD with PHP on my N66U with asuswrt merlin, Entware is not necessary.

Thanks to TeHashX's Cherokee and Lighttpd tutorials.

We need a usb-flash formatted EXT2 or a usb-hdd formated EXT3, may not work on FAT32 or NTFS and Optware installed (install Downloadmaster from Asus).
Login to router with putty/terminal and enter commands:
Code:
# ipkg update
# ipkg upgrade
# ipkg install php-thttpd

the php-thttpd package contains both the webserver and the php environment.

Install nano and change the thttpd configuration:
Code:
# ipkg install nano
# nano /opt/etc/thttpd.conf
Change the folder
Change the port (port 80 is for asus admin panel)

my example:
thttpdconf.jpg

Save (ctrl+o) and exit nano (ctrl+x)

Set folder permission (in my case is /mnt/media/FTP/www, change the /path/to/folder with your folder)
Code:
# chmod 777 /path/to/folder

Create a simple index.php file inside
Code:
# nano /path/to/folder/index.php
Write inside
Code:
<?php phpinfo(); ?>
Save (ctrl+o) and exit nano (ctrl+x)
Set permissions
Code:
# chmod 777 /path/to/folder/index.php

Now we must setup the startup script. The php-thttpd package created the init script S80thttpd but the asus script app_set_enabled.sh doesn't recognize it because the package name isn't thttpd but is php-thttpd, so we must create a new init script with the package name (copy of original thttpd) and enable at startup:
Code:
# cp /opt/etc/init.d/S80thttpd /opt/etc/init.d/S80php-thttpd
# chmod a+rx /opt/etc/init.d/S80php-thttpd
# app_set_enabled.sh php-thttpd yes

- Reboot
- Open http://192.168.1.1:8001 (change 8001 with your port set in your thttpd.conf before) if you see the php info, all is right!
thttpdphpinfo.jpg


Now, we need to set the firewall to make it accessible via wan, we need asus merlin firmware and jffs enabled:
Code:
# nano /jffs/scripts/firewall-start

Add this lines (change 8001 with your port)
Code:
#!/bin/sh
iptables -I INPUT -p tcp --destination-port 8001 -j ACCEPT

Save, exit nano and set permission
Code:
# chmod a+rx /jffs/scripts/firewall-start

Go to port forwarding and redirect port 80 to 8001 (or your port):
portforwardthttpd.jpg


After reboot should you have access from wan.
 
Last edited:
Similar threads

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top