Lighttpd Web Server with PHP Support through Entware

A - For Mipsel devices setup Entware from this guide (see youtube video here)

B - For Arm devices setup Entware-Arm from this guide

Paste this commands in terminal:

opkg install lighttpd php5-cgi lighttpd-mod-fastcgi lighttpd-mod-scgi nano
/opt/etc/init.d/S80lighttpd stop
mkdir -p /opt/etc/lighttpd/conf.d
opkg install wget
rm /opt/etc/lighttpd/conf.d/*
wget -c -O /opt/etc/lighttpd/conf.d/99-rtorrent-fastcgi-scgi-auth.conf http://goo.gl/xAT5yv
wget -c -O /opt/share/www/index.html http://goo.gl/3cBVYs
sed -i "/server.upload-dirs*/cserver.upload-dirs          = ( \"/opt/tmp\" )" "/opt/etc/lighttpd/lighttpd.conf"
/opt/etc/init.d/S80lighttpd start

Go to 192.168.1.1:81 and if you see this page, the lighttpd web server is configured correctly
lighttpd1

To verify if php is enabled, create an info script

nano /opt/share/www/info.php

Paste this code:

<?php
phpinfo();
?>

Save with CTRL-O / Enter / and exit with CTRL-X

Go to 192.168.1.1:81/info.php and if you see this page, the php-mod-fastcgi is configured correctly

lighttpd-php

 

TO ACCESS THE WEBSITE FROM WAN
--------------------------------------------------------------------------

nano /jffs/scripts/firewall-start

Paste this lines

#!/bin/sh
iptables -I INPUT -p tcp --destination-port 81 -j ACCEPT

 Save with CTRL-O / Enter / and exit with CTRL-X
chmod a+rx /jffs/scripts/firewall-start

Go to Port Forwarding page http://192.168.1.1/Advanced_VirtualServer_Content.asp and redirect port 80 to 81, after reboot you should have access from wan.

lighttpd-portfw

Video HERE...

youtube

 

Thanks @ryzhov_al & @zyxmon

  • Rob Huijben

    I followed the instructions, installed entware on my Asus router and installed lightttpd and configured it as shown above, but I can't seem to run the service. Lighttpd tells me the service is started, but wen I look at the running services, it isn't there. Any advice on how to get it running?

  • Tiberius Cato

    is it possible to get lighttpd upgraded to the latest version with all modules (modproxycore etc) support and also if possible add the php extensions aspell and imap please :) thanks for such a great environment to work with pitty no gcc or build tools in opkg so i could do this myself i didn't want to use debian that way im using less resources :)

  • user

    how to config another port for lighttpd?
    myconfig:
    Port Forwarding

    Service Name Port Range Local IP Local Port Protocol
    remote access 9400 router ip 81 both

    firewall
    iptables -I INPUT -p tcp --destination-port 9400 -j ACCEPT
    iptables -I INPUT -p udp --destination-port 9400 -j ACCEPT
    can not access from wan!

    config#2

    Service Name Port Range Local IP Local Port Protocol
    remote access 81 router ip 81 both

    firewall
    iptables -I INPUT -p tcp --destination-port 81 -j ACCEPT
    iptables -I INPUT -p udp --destination-port 81 -j ACCEPT
    wan access Success.
    for the Security issue,I want to change the default port.
    which file should i edit?

  • Edison

    Is it possible to bind service on localhost (127.0.0.1) and forward port from WAN 80 to 127.0.0.1:81? My firmware is asuswrt-merlin.

  • Newton

    I can't run test.php. It shows "403 - Forbidden". What's wrong?

    • Newton

      ".php" should be removed from in lighttpd.conf

  • Rik

    Is there a php with freetype support available for this? Using the current instructions, I get '--without-freetype-dir' in the php config.

  • Roy

    Is the WordPress permalink supported? Is the rewrite supported?

  • NoRouter

    Worked fine for me. Literally tried it 10 mins ago. Thanks TeHashx

    • Don't forget to subscribe to receive notifications when new tutorials are posted

  • Ramasjang

    Can not connect to 192.168.1.1:81/test.php

    admin@Airport:/tmp/mnt/sda2/entware# wget -c -O /opt/share/www/index.html http:/

    /goo.gl/ZPEv73

    Connecting to goo.gl (92.246.5.27:80)

    Connecting to hqt.ro (91.216.151.23:80)

    wget: server returned error: HTTP/1.1 416 Requested Range Not Satisfiable

    admin@Airport:/tmp/mnt/sda2/entware#

    • Ramasjang

      When I try to start lighttpd from terminal, I get this on router system log:

      Nov 15 13:48:24 admin: Started lighttpd from .

      • error: HTTP/1.1 416 Requested Range Not Satisfiable
        The file is already there

        Reboot router, lighttpd should work

      • Ramasjang

        After reboot:

        admin@Airport:/tmp/home/root# /opt/etc/init.d/S80lighttpd start

        Starting lighttpd... done.

        admin@Airport:/tmp/home/root# /opt/etc/init.d/S80lighttpd check

        Checking lighttpd... dead.

        admin@Airport:/tmp/home/root# /opt/etc/init.d/S80lighttpd start

        Starting lighttpd... done.

        admin@Airport:/tmp/home/root# /opt/etc/init.d/S80lighttpd check

        Checking lighttpd... dead.

        admin@Airport:/tmp/home/root#

        From router:

        Nov 15 13:57:16 admin: Started lighttpd from .

        Nov 15 13:57:30 admin: Started lighttpd from .

        Still no access to 192.168.1.1:81

      • to check why it's not running, type:
        lighttpd -f /opt/etc/lighttpd/lighttpd.conf

      • Ramasjang

        admin@Airport:/tmp/home/root# lighttpd -f /opt/etc/lighttpd/lighttpd.conf

        2014-11-15 14:47:34: (plugin.c.169) dlopen() failed for: /opt/lib/lighttpd/mod_scgi.so File not found

        2014-11-15 14:47:34: (server.c.679) loading plugins finally failed

      • opkg install lighttpd-mod-scgi

      • Ramasjang

        admin@Airport:/tmp/home/root# lighttpd -f /opt/etc/lighttpd/lighttpd.conf

        2014-11-15 15:11:02: (plugin.c.131) Cannot load plugin mod_scgi more than once, please fix your config (we may not accept such configs in future releases

        It is working now, have access to 192.168.1.1:81

SoftEther VPN Running on AsusWRT Routers
Minidlna UPnP Media Server through Debian Jessie Arm
How to Mount Samba Shares inside Chrooted Debian
Nginx Web Server with PHP Support through Optware-NG
Minidlna UPnP Media Server through Debian Jessie Arm
How to Mount Samba Shares inside Chrooted Debian
Spreed WebRTC server and web client
Asterisk VoIP Server running on AsusWRT Routers
SoftEther VPN Running on AsusWRT Routers
NZBGet through Entware
Minidlna UPnP Media Server through Debian Jessie Arm
NetData System Monitor Entware

SUBSCRIBE

To be notified by email when a new tutorial is posted :)

Thanks for Subscribing! I'll keeping you up-to-date with latest tutorials!

Something went wrong, try again...