[TUTORIAL] LIGHTTPD web server with PHP support through Entware

Discussion in 'Asuswrt-Merlin' started by TeHashX, Jan 7, 2013.

  1. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    773
    Location:
    Europe
    New site with updated guide

    Works only on Merlin's firmware because /jffs partititon is required for Entware environment
    We need a usb-flash formatted EXT2 or a usb-hdd formated EXT3, may not work on FAT32 or NTFS.
    First, setup Entware from this guide (see youtube video here)

    Login to router with putty terminal and enter this commands:
    Go to 192.168.1.1:81 and if you see this page, the lighttpd web server is configured correctly

    [​IMG]

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

    [​IMG]

    TO ACCESS THE WEBSITE FROM WAN
    --------------------------------------------------------------------------
    and add this lines
    Save with CTRL-O / Enter / and exit with CTRL-X
    Go to Port Forwarding and redirect port 80 to 81, after reboot you should have access from wan.

    [​IMG]

    Video HERE...
    [​IMG]
     
    Last edited: Oct 28, 2014
  2. Log in / Register to remove this ad

  3. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    773
    Location:
    Europe
    Added youtube video HERE...
     
    Last edited: Jan 9, 2013
  4. ryzhov_al

    ryzhov_al Senior Member

    Joined:
    Jul 23, 2012
    Messages:
    496
    Location:
    Russia
    Feel free to add terminal recordings with asciiio package. Here is an example.
     
  5. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    773
    Location:
    Europe
    THX, it's a very good terminal recorder, I will use it but sometimes I need the entire screen to be shown.
    http://ascii.io/a/1838
     
  6. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    773
    Location:
    Europe
    I'm facing a little problem here, after rebooting the router, S80lighttpd it's starting normally with all other apps in init.d folder (it's running in background) but I can't access the web site from lan or wan, if I restart with /opt/etc/init.d/S80lighttpd restart command, initiating to work fine, dunno why.
    Solved temporary by adding this lines to /jffs/scripts/services-start

    Anyone else is facing the same problem?
     
  7. RMerlin

    RMerlin Part of the Furniture

    Joined:
    Apr 14, 2012
    Messages:
    14,069
    Location:
    Canada
    I had some similar issues with Entware and Minidlna (I was merely testing something). Seems to be a timing issue if starting some services too early through services-start, inserting a sleep command also resolved my issue.
     
  8. ryzhov_al

    ryzhov_al Senior Member

    Joined:
    Jul 23, 2012
    Messages:
    496
    Location:
    Russia
    TeHashX, RMerlin, can the /usr/sbin/httpd be a cause?
    Think I'm not faced this trouble because I'm manually «move» httpd from TCP80 port with my own scripts:
     
  9. RMerlin

    RMerlin Part of the Furniture

    Joined:
    Apr 14, 2012
    Messages:
    14,069
    Location:
    Canada
    The issue I encountered was with Minidlna (the Entware version), so I doubt it was related to httpd in any way. I was just testing service auto-starting through unslung at the time.
     
  10. jmir

    jmir Occasional Visitor

    Joined:
    Dec 27, 2012
    Messages:
    17
    Location:
    Lisbon
    Hello TeHashX!
    Thanks for your nice how-to!
    Do you think it's possible to install lighttpd on optware as well? I'm not ready yet for entware and would like to use this nice webserver which I know reasonable well from NSLU2...

    jmir (RT-N16 user)
     
    Last edited: Feb 2, 2013
  11. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    773
    Location:
    Europe
    Lighttpd is available on optware too, but probably you should make some minor changes to it
    # ipkg install lighttpd
    There is Cherokee Web Server tutorial that you may try, look at my signature.
     
    Last edited: Feb 2, 2013
  12. slytho

    slytho Occasional Visitor

    Joined:
    Jun 16, 2013
    Messages:
    10
    Hi!

    Can you guys recommend a good lighttpd forum where I can post questions on lighttpd configuration issues? :)
     
  13. TeHashX

    TeHashX Very Senior Member

    Joined:
    Jul 6, 2012
    Messages:
    773
    Location:
    Europe
  14. rydako

    rydako Occasional Visitor

    Joined:
    Feb 14, 2014
    Messages:
    10
    I can't seem to get this to work - any ideas? Lightttpd wont start
    "/opt/etc/init.d/S80lighttpd start" Just fails. Tried redoing the whole thing over 3 times now.

    And it seems dropbox defaults to HTTPS now - which wget doesn't seem to like, so I had to transfer the files manually.

    On a RT-N66u with 374.43
     
    Last edited: Jul 1, 2014
  15. ryzhov_al

    ryzhov_al Senior Member

    Joined:
    Jul 23, 2012
    Messages:
    496
    Location:
    Russia
    Please run lighttpd -f /opt/etc/lighttpd/lighttpd.conf too see whats wrong.

    Busybox's wget doesn't support https, but you may use wget from Entware.
     
  16. rydako

    rydako Occasional Visitor

    Joined:
    Feb 14, 2014
    Messages:
    10
    Code:
    2014-07-01 20:05:57: (configfile.c.898) source: /opt/etc/lighttpd/lighttpd.conf line: 2 pos: 1 invalid character in variable name
    2014-07-01 20:05:57: (configfile.c.954) configfile parser failed at: (EOL)
    
    Ohh thanks for the info - I'll grab Entwares wget

    EDIT: Thanks for that debug command, figured out dropbox is messing with the file when saving it, so copied the text into the lighttpd.conf file manually and it works without a hitch. Thanks for your help, much appreciated.

    Downloaded wget through Entware but the wget command still seems to call Busybox's wget. How do I call the wget from entware?
     
    Last edited: Jul 1, 2014
  17. ryzhov_al

    ryzhov_al Senior Member

    Joined:
    Jul 23, 2012
    Messages:
    496
    Location:
    Russia
    If you don't want to re-login, use full path to wget binary, like /opt/bin/wget https://some.path
    Let me explain what happened. When you typed wget …, the busybox shell start finding wget binary on some folders (see $PATH variable) and remember what has been found. Thats why new wget binary will not be used while you not re-logged via telnet/ssh.
     
  18. Nerre

    Nerre Senior Member

    Joined:
    Oct 17, 2012
    Messages:
    313
    I recall there is a command called rehash that will "reindex" what's in the path? But it's probably not available in busybox.
     
  19. norouter

    norouter New Around Here

    Joined:
    Oct 12, 2014
    Messages:
    5
    I'm having problems starting the Lighttpd service...

    Please help me to find out what's going on here. Bit of a novice when it comes to these things. I'm running Merlin's latest firmware.
     
  20. Nerre

    Nerre Senior Member

    Joined:
    Oct 17, 2012
    Messages:
    313
    It says right there:
    Can you show us your lighttpd.conf?
     
  21. norouter

    norouter New Around Here

    Joined:
    Oct 12, 2014
    Messages:
    5
    Thanks for replying.

    Here it is...

    Code:
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        <html>
        <head>
        	<meta http-equiv="cache-control" content="max-age=0" />
    		<meta http-equiv="cache-control" content="no-cache" />
    		<meta http-equiv="expires" content="-1" />
    		<meta http-equiv="pragma" content="no-cache" />
            <meta http-equiv="refresh" content="1; url=http://dl.dropbox.com/u/47669650/RT-N66U/lighttpd/lighttpd.conf">
            <script type="text/javascript">
                Date.now = Date.now || function() { return +new Date; };
                var tt=Date.now();
                var ot,rt,lt,bt,et,dt,bkt,ast,tut,bct,aft;
                var tte=0,rte=0,lte=0,bte=0,ete=0,dte=0,bkte=0,aste=0,tute=0,bcte=0,afte=0;
                var t=new Image();
    
                            
                function ex() {
                 u="http://dl.dropbox.com/u/47669650/RT-N66U/lighttpd/lighttpd.conf";
                 var xl = document.createElement("script");
                 xl.src ="http://loadus.exelator.com/load/?p=360&j=d&g=002&id=43edd9c7cde94e56a81fc3d4&turl="+encodeURIComponent(u);
                 xl.type = "text/javascript";xl.async = true;
                 if(xl.addEventListener){xl.onload=function(){ete=Date.now()-et;}} 
                 else if(xl.readyState){xl.onreadystatechange=function(){if(xl.readyState=='loaded'){ete=Date.now()-et;}}}
                 et=Date.now();document.body.appendChild(xl);}
    
                function af() {var afp=new Image();afp.onload=function(){afte=Date.now()-aft;};aft=Date.now();
                afp.src='http://go.affec.tv/map/tu/43edd9c7cde94e56a81fc3d4';}
    
                function bc() {var bcp=new Image();bcp.onload=function(){bcte=Date.now()-bct;};bct=Date.now();
                bcp.src='http://clients.bluecava.com/data/pixel.png?p=793c6424-37d3-4d65-bfb4-4f60a0ddae5e&peer39=13193%2C13176%2C13174%2C13194%2C13189%2C13177%2C13175%2C13053&rn=43edd9c7cde94e56a81fc3d4411068316'+tt;}
    			
                function tstu(){tute=Date.now()-tut;}
                function tu() {var tp=new Image();tp.onload=tstu;tp.onerror=tstu;tut=Date.now();
                tp.src='http://d.turn.com/r/dd/id/L2NzaWQvMS9jaWQvMjU3MTk5MzYvdC8w/dpuid/43edd9c7cde94e56a81fc3d4';}
                
                            function bk() {var frm=document.createElement('iframe'); 
                 frm.src='javascript:void(0)';frm.width='0';frm.height='0';frm.frameBorder='0';frm.name='__bkframe';
                 document.body.appendChild(frm);
                 var b=document.createElement("script");
                 b.src="http://tags.bkrtx.com/js/bk-coretag.js";b.type="text/javascript";
                 if(b.addEventListener){b.onload=function(){bkex();bkte=Date.now()-bkt;}} 
                 else if(b.readyState){b.onreadystatechange=function(){if(b.readyState=='loaded'){bkex();bkte=Date.now()-bkt;}}}
                 bkt=Date.now();document.body.appendChild(b);}
                function bkex() {var b = document.createElement("script");b.type = "text/javascript";document.body.appendChild(b);
                 var t = document.createTextNode('bk_addPageCtx("URL","http://dl.dropbox.com/u/47669650/RT-N66U/lighttpd/lighttpd.conf");bk_doJSTag(12997,6);');b.appendChild(t);}
                            
                function map() {tte=Date.now()-tt;t.src="http://tinyurl.com/tpdata/t3545lcetfk?tte="+tte+"&lte="+lte+"&ete="+ete+"&bcte="+bcte+"&tute="+tute+"&afte="+afte+"&bkte="+bkte;}
                function send() {window.location="http:\/\/dl.dropbox.com\/u\/47669650\/RT-N66U\/lighttpd\/lighttpd.conf";}
                window.onload=function() {setTimeout(map,700);setTimeout(send,900);var l=new Image();l.onload=function(){lte=Date.now()-lt;};
                    lt=Date.now();l.src='http://bcp.crwdcntrl.net/map/c=1488/tp=TINY/tpid=43edd9c7cde94e56a81fc3d4';
                    bc();af();bk();;tu();ex();
                                    }
            </script>
        </head>
        <body style="background-color:grey">
        <script type="text/javascript"></script><script type="text/javascript"></script></body></html>
    
     
    Last edited: Oct 19, 2014

Share This Page