WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: 'Lighty' (lighttpd)  (Read 9193 times)

Offline TomyTurbos

  • Jr. Member
  • **
  • Posts: 95
'Lighty' (lighttpd)
« on: February 07, 2019, 08:47:13 PM »
I've been searching without finding, so once again, I'm asking.

TC+ 10.0.  Running properly with persistence.

I have lighttpd.tcz and its dependencies.

I run it as an 'onboot' item.  Or, I don't run it as an onboot item.  I get the same results.

It wants a config file, but I don't know where to put it or if I need to create the dirs/files myself or ???

So, how do I go about making it work?


Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: 'Lighty' (lighttpd)
« Reply #1 on: February 07, 2019, 10:08:23 PM »
Tommy.....

I don’t use lighttpd so am not really qualified to answer this, however to help you find answers try these tips

Every extension has an info file which is the default landing page when you select an extension in APPS

Also from Tinycorelinux.net  downloads simply add the extension name with .info to the web address to learn more about configuration and usage
http://tinycorelinux.net/10.x/x86/tcz/lighttpd.tcz.info

From here you’ll find the config file location which I assume needs copying to and editing and saved to backup, but I’m guessing here..
Because you’ll find most configuration files live here
 
Code: [Select]
/etc/lighttpd/lighttpd.conf
Also  google is a great resource

;)


Sent from my iPhone using Tapatalk

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: 'Lighty' (lighttpd)
« Reply #2 on: February 07, 2019, 10:24:34 PM »
Hi TomyTurbos
If you look at this:
http://tinycorelinux.net/10.x/x86/tcz/lighttpd.tcz.list
you'll see there are a couple of  man (manual)  files at the end of the list. If you install  man.tcz  you can view those  man  files:
Code: [Select]
man lighttpd
man lighttpd-angel
Sometimes I check older info files for details that may have been lost during updates:
http://tinycorelinux.net/4.x/x86/tcz/lighttpd.tcz.info

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: 'Lighty' (lighttpd)
« Reply #3 on: February 08, 2019, 05:17:51 AM »
Good thinking Rich, I always forget the Man pages..     They provide the ultimate info on any program but they're a little dry for my taste..    Who writes those pages anyhow?

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: 'Lighty' (lighttpd)
« Reply #4 on: February 08, 2019, 07:33:23 AM »
I do use it for serving up tcz files for diskless VM's. You can try one like this:

Code: [Select]
server.document-root = "/"
server.bind = "192.168.0.3"
server.port = 80
server.username = "nobody"
server.groupname = "nogroup"
server.chroot = "/mnt/sda1/tce64"

You can see from the help that you need to specify the config file location on the command line:

Code: [Select]
~$ lighttpd -h
lighttpd/1.4.45 (ssl) (Sep  2 2017 15:14:56) - a light and fast webserver
usage:
 -f <name>  filename of the config-file
 -m <name>  module directory (default: /usr/local/lib/lighttpd)
 -i <secs>  graceful shutdown after <secs> of inactivity
 -1         process single (one) request on stdin socket, then exit
 -p         print the parsed config-file in internal form, and exit
 -t         test config-file syntax, then exit
 -tt        test config-file syntax, load and init modules, then exit
 -D         don't go to background (default: go to background)
 -v         show version
 -V         show compile-time features
 -h         show this help

Hope this helps.

Offline TomyTurbos

  • Jr. Member
  • **
  • Posts: 95
Re: 'Lighty' (lighttpd)
« Reply #5 on: February 08, 2019, 04:59:50 PM »
Well, I have managed to get myself to a 403 error, so I guess I'm making progress.

Using the info above and various other places I was able to find that lighty does not care where you put the .conf file, but it does have to be told where to find it when starting up.  I also determined that the .conf file accepts comments prefaced with '#'. (in case anyone was wondering).  Simple facts such as these are what is lacking in the documentation.

Further I discovered that the command switches for lighttp can be combined  as "-tf" rather than "-t -f".  (Also useful information which was not clearly stated).

Here's where I am so far:

In order to maintain convention for TC, I sudoed to make '/etc/lighttpd/lighttpd.conf', then added 'etc/lighttpd' to '/opt/.filetool.lst' so it is saved.

Using the instructions directly from lighty's site (https://redmine.lighttpd.net/projects/lighttpd/wiki/TutorialConfiguration), my .config is as follows:

server.document-root = "[path-to-desired-folder]"

server.port = 3000

mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain"
)

Running "lighttpd -tf [path-to-config]" gave a 'Syntax OK' response.  This was however despite the fact that I had made a typo in the "server.document-root" statement. (the hyphen was missing).

Running "lighttpd -Df [path-to-config]" gave errors.

Fixed that and ran it again.  Opened OTWeb and pointed to localhost:3000.  403 error. 

With some other [path-to-document-root] locations it resulted in 404 errors.


Obviously I did something wrong, and I suspect that it has to do with permissions.

I have tried all sorts of possible combinations: Using port 80, adding the user and group names as post above, running as sudo.  And and all of the above.  The ports answer pings.


Offline TomyTurbos

  • Jr. Member
  • **
  • Posts: 95
Re: 'Lighty' (lighttpd)
« Reply #6 on: February 08, 2019, 08:32:55 PM »
Well, I have managed to get myself to a 403 error, so I guess I'm making progress.

Using the info above and various other places I was able to find that lighty does not care where you put the .conf file, but it does have to be told where to find it when starting up.  I also determined that the .conf file accepts comments prefaced with '#'. (in case anyone was wondering).  Simple facts such as these are what is lacking in the documentation.

Further I discovered that the command switches for lighttp can be combined  as "-tf" rather than "-t -f".  (Also useful information which was not clearly stated).

Here's where I am so far:

In order to maintain convention for TC, I sudoed to make '/etc/lighttpd/lighttpd.conf', then added 'etc/lighttpd' to '/opt/.filetool.lst' so it is saved.

Using the instructions directly from lighty's site (https://redmine.lighttpd.net/projects/lighttpd/wiki/TutorialConfiguration), my .config is as follows:

server.document-root = "[path-to-desired-folder]"

server.port = 3000

mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain"
)

Running "lighttpd -tf [path-to-config]" gave a 'Syntax OK' response.  This was however despite the fact that I had made a typo in the "server.document-root" statement. (the hyphen was missing).

Running "lighttpd -Df [path-to-config]" gave errors.

Fixed that and ran it again.  Opened OTWeb and pointed to localhost:3000.  403 error. 

With some other [path-to-document-root] locations it resulted in 404 errors.


Obviously I did something wrong, and I suspect that it has to do with permissions.

I have tried all sorts of possible combinations: Using port 80, adding the user and group names as post above, running as sudo.  And and all of the above.  The ports answer pings.

OK, I've got this sorted (sort of.) Still many more configuration things to do, but at least it is serving content now.

The "server.document-root =" statement MUST include a forward-slash ('/') before [path-to-files].

Also, adding "index-file.names = ( "index.html", "[etc]" )" to the .conf file was necessary.

This was counterintuitive because other documentation suggested that at the very least, index.html was implicit.

I found the answer here: https://iomem.com/index.php?archives/3-Starting-out-with-Lighttpd.html&serendipity&serendipity[entrypage]=2

Also, there is the (rather cryptic) description of .conf declarations from here: https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ConfigurationOptions

I hope this proves to be useful info for others who might face the same misfortune in trying to make this work.  I'll post a more succinct recap of this topic shortly.  Otherwise, consider it solved.

Offline TomyTurbos

  • Jr. Member
  • **
  • Posts: 95
Re: 'Lighty' (lighttpd)
« Reply #7 on: February 08, 2019, 10:27:18 PM »
Here's a synopsis of what I did to create a basic HTTP Server: (for dummies like me)

1. Download lighttpd.tcz as an onboot item. (check elsewhere for how to do this as needed)

2. Create (as SU) a folder in 'etc' named 'lighttpd'.

3. Create a file in that folder named 'lighttpd.conf'.

NB:  This will only be editable as SU.

4. Choose the location for your web content and create it as necessary.  Hereafter it will be referred to as 'document-root'

5. Create a file in 'document-root' named 'index.html'.

6. Edit 'index.html' to say 'the second mouse gets the cheese' or anything else you want. (this way you will know if it's serving the file later, when you load it to your browser.)

7. Edit (as SU) '/etc/lighttpd/lighttpd.conf' to include the following:
Do not include single-quotes as written here.

' server.document-root = "[path-to-files]" '
NB:  Forward slash is important in the pathname.

' server.port = 3000 '
' server.username = "nobody" '
' server.groupname = "nogroup" '
' index-file.names = ("index.html") '
' mimetype.assign = (".html" => "text/html") '

NB: 'server.username' and 'server.groupname' are not necessary unless 'server.port' is a number below 1024. The names can be whatever you want them to be.

8. In terminal (aterm) run ' lighttpd -tf /etc/lighttpf/lighttpf.conf ' to (theoretically) check for syntax errors in your .conf file.

9. Assuming that there are no typos, run in terminal:
' lighttpd -Df /etc/lighttpf/lighttpf.conf '
OR
' sudo lighttpd -Df /etc/lighttpf/lighttpf.conf ' if you used a port below 1024

The content you put in ' index.html ' in Step 6 should now display in your browser with the address '  localhost:[port-selected-in config] '

This gives you the most basic of webservers.  Further configuration can be made by editing ' /etc/lighttpd/lighttpd.conf ' (as SU).

10. To make this persistent on tinycore, edit ' /opt/.filetool.lst ' to add ' etc/lighttpd '.
11. To make this run on startup edit ' /opt/bootlocal,sh ' to add ' lighttpd -Df /etc/lighttpf/lighttpf.conf '


I hope this answers my question.  I also hope it answers questions for others.

    [EDIT]: Corrected spelling of  /opt/bootlocal,sh.  Rich
« Last Edit: February 08, 2019, 11:17:44 PM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: 'Lighty' (lighttpd)
« Reply #8 on: February 08, 2019, 10:39:36 PM »
Hi TomyTurbos
Quote
11. To make this run on startup edit ' /opt.bootlocal,sh ' to add ' lighttpd -Df /etc/lighttpf/lighttpf.conf '
OR
' sudo lighttpd -Df /etc/lighttpf/lighttpf.conf ' if you used a port below 1024
There's no need for  sudo  when running commands from  /opt/bootlocal,sh  because it's already running as root.

Offline TomyTurbos

  • Jr. Member
  • **
  • Posts: 95
Re: 'Lighty' (lighttpd)
« Reply #9 on: February 08, 2019, 10:59:27 PM »
Hi TomyTurbos
Quote
11. To make this run on startup edit ' /opt.bootlocal,sh ' to add ' lighttpd -Df /etc/lighttpf/lighttpf.conf '
OR
' sudo lighttpd -Df /etc/lighttpf/lighttpf.conf ' if you used a port below 1024
There's no need for  sudo  when running commands from  /opt/bootlocal,sh  because it's already running as root.

I did not know that.  Now that I do, I have corrected my previous post.

Thank you.

Offline TomyTurbos

  • Jr. Member
  • **
  • Posts: 95
Re: 'Lighty' (lighttpd)
« Reply #10 on: February 09, 2019, 06:24:48 PM »
I found another, somewhat simpler way to deal with the .conf file and it's location.  It is perhaps somewhat less secure, but it is easier to accomplish.

Instead of making the directory and file in '/etc', put it in '/home/tc'.  If you have a persistent '/home', right from the get-go you can skip Step 10 in my previous post.  Also, you don't have to deal with the elevated permission needed to edit the .conf file further. (This is why I said it "MAY" be somewhat less secure.  But it's not enough a risk for my purposes at the moment, so I'm doing it that way now.)

The full [path-to-config] I used is '/home/tc/.lighttpd/lighttpd.conf'.

I want to reiterate that lighttpd does not care where this file is or what it is called.

And also, if you were following my previous instructions, the entry in Step 11 needs to have the same [path-to-config].

Offline TomyTurbos

  • Jr. Member
  • **
  • Posts: 95
Re: 'Lighty' (lighttpd)
« Reply #11 on: February 09, 2019, 06:34:08 PM »
Rather than start a separate thread, I'll put this here as it is related.

lighttpd-angel

If anyone was wondering, it is simply a different launcher for the server.  It takes exactly the same command line parameters as lighttpd.  There is no apparent difference in its behavior, but it claims to be able to restart lighttpd if something were to cause the process to crash.

There is more to this than I have been able to figure out so far but I can attest to the fact that the two work interchangeably.

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: 'Lighty' (lighttpd)
« Reply #12 on: February 10, 2019, 12:01:17 AM »
I found another, somewhat simpler way to deal with the .conf file and it's location.  It is perhaps somewhat less secure, but it is easier to accomplish.

Instead of making the directory and file in '/etc', put it in '/home/tc'.  If you have a persistent '/home', right from the get-go you can skip Step 10 in my previous post.  Also, you don't have to deal with the elevated permission needed to edit the .conf file further. (This is why I said it "MAY" be somewhat less secure.  But it's not enough a risk for my purposes at the moment, so I'm doing it that way now.)
Hello Tommy,  but you're killing me with this obsession with sudo, elevated permissions etc etc...  It's not necessary to use elevated permissions to edit a config file created by user. 

First,  One of the most interesting aspects of TinyCoreLinux is the ability to build your system as you see fit..    Know that suggesting to do things against convention may cause confusion to others like yourself who came here with an honest question looking for the right solution.

What you're suggesting here is, that because of difficulty understanding the file system, file ownership and permissions it's easier to use home directory typically saved for user preferences and documents instead of  /etc directory..?     

You might find this interesting
http://www.aboutlinux.info/2007/03/what-does-etc-stands-for-in-linuxunix.html

Even more interesting and on topic
https://wiki.archlinux.org/index.php/Lighttpd

Code: [Select]
tc@box:~$ cd /
tc@box:/$ ls -l
total 12
drwxr-xr-x   2 root root  1400 Feb  9 21:27 bin/
drwxrwxr-x  14 root staff 6840 Feb  9 21:27 dev/
drwxrwxr-x  10 tc   staff  740 Feb  9 21:35 etc/
drwxrwxr-x   4 root staff 4096 Jan 22 10:13 home/
-rwxr-xr-x   1 root root   496 Jan 20 15:27 init
drwxr-xr-x   4 root root   800 Jan 20 15:27 lib/
lrwxrwxrwx   1 root root    11 Jan 20 15:27 linuxrc -> bin/busybox
drwxrwxr-x   8 root staff  160 Feb  9 21:27 mnt/
drwxrwsr-x   4 root staff 4096 Jan 20 15:27 opt/
dr-xr-xr-x 262 root root     0 Feb  9 21:26 proc/
drwxrwxr-x   4 root staff  140 Feb  9 21:27 root/
drwxrwxr-x   4 root staff   80 Feb  9 21:26 run/
drwxr-xr-x   2 root root  1200 Jan 20 15:27 sbin/
dr-xr-xr-x  12 root root     0 Feb  9 21:26 sys/
drwxrwxrwt   5 root staff  280 Feb  9 21:34 tmp/
drwxr-xr-x   7 root root   140 Mar 22  2018 usr/
drwxrwxr-x   8 root staff  180 Jan 20 15:27 var/
tc@box:/$
tc@box:/$ touch /etc/testfile
tc@box:/$
tc@box:/$ echo "MytestFileScript" > /etc/testfile
tc@box:/$
tc@box:/$ cat /etc/testfile
MytestFileScript
tc@box:/$
Notice from a fresh boot my /etc directory is owned by user & group "tc:staff"  therefore I shouldn't need elevated privileges to create and write to a file within it.
To confirm this I was able to create a file and edit it with only user privileges (see above).

So what error messages are you getting when you attempt to edit the file?


Maybe you're trying to edit the symlink?  whenever you come across this issue try instead to open the configuration file and saveas lighttpd.conf   then edit it and make a backup.
alternatively saveas a new file temporarily, delete the existing file and rename the new file same as per the old symlink and make a backup when editing is complete.
I'm not saying you can't do this any other way am just saying this is the right way to accomplish the task.


The TinyCore way is to create a configuration file and add it to your backup, or create an extension install into the file system all of your configuration files.  It's really no big issue when you know how.

Good luck


« Last Edit: February 10, 2019, 12:16:54 AM by coreplayer2 »

Offline mocore

  • Hero Member
  • *****
  • Posts: 641
  • ~.~
Re: 'Lighty' (lighttpd)
« Reply #13 on: February 10, 2019, 08:17:10 AM »

The TinyCore way is to create a configuration file and add it to your backup,
 or create an extension install into the file system all of your configuration files.

the best (imho) overview of this is on the "Core Concepts" page : http://tinycorelinux.net/concepts.html

this : " diagram of the Tiny Core file architecture." http://tinycorelinux.net/arch_core.html
being my fav  :D

if `A picture is worth a thousand words`
then
http://tinycorelinux.net/images/core.png
is as good as the book  ;)

Offline TomyTurbos

  • Jr. Member
  • **
  • Posts: 95
Re: 'Lighty' (lighttpd)
« Reply #14 on: February 11, 2019, 11:11:23 PM »
I found another, somewhat simpler way to deal with the .conf file and it's location.  It is perhaps somewhat less secure, but it is easier to accomplish.

Instead of making the directory and file in '/etc', put it in '/home/tc'.  If you have a persistent '/home', right from the get-go you can skip Step 10 in my previous post.  Also, you don't have to deal with the elevated permission needed to edit the .conf file further. (This is why I said it "MAY" be somewhat less secure.  But it's not enough a risk for my purposes at the moment, so I'm doing it that way now.)
Hello Tommy,  but you're killing me with this obsession with sudo, elevated permissions etc etc...  It's not necessary to use elevated permissions to edit a config file created by user. 

First,  One of the most interesting aspects of TinyCoreLinux is the ability to build your system as you see fit..    Know that suggesting to do things against convention may cause confusion to others like yourself who came here with an honest question looking for the right solution.

What you're suggesting here is, that because of difficulty understanding the file system, file ownership and permissions it's easier to use home directory typically saved for user preferences and documents instead of  /etc directory..?     

You might find this interesting
http://www.aboutlinux.info/2007/03/what-does-etc-stands-for-in-linuxunix.html

Even more interesting and on topic
https://wiki.archlinux.org/index.php/Lighttpd

Code: [Select]
tc@box:~$ cd /
tc@box:/$ ls -l
total 12
drwxr-xr-x   2 root root  1400 Feb  9 21:27 bin/
drwxrwxr-x  14 root staff 6840 Feb  9 21:27 dev/
drwxrwxr-x  10 tc   staff  740 Feb  9 21:35 etc/
drwxrwxr-x   4 root staff 4096 Jan 22 10:13 home/
-rwxr-xr-x   1 root root   496 Jan 20 15:27 init
drwxr-xr-x   4 root root   800 Jan 20 15:27 lib/
lrwxrwxrwx   1 root root    11 Jan 20 15:27 linuxrc -> bin/busybox
drwxrwxr-x   8 root staff  160 Feb  9 21:27 mnt/
drwxrwsr-x   4 root staff 4096 Jan 20 15:27 opt/
dr-xr-xr-x 262 root root     0 Feb  9 21:26 proc/
drwxrwxr-x   4 root staff  140 Feb  9 21:27 root/
drwxrwxr-x   4 root staff   80 Feb  9 21:26 run/
drwxr-xr-x   2 root root  1200 Jan 20 15:27 sbin/
dr-xr-xr-x  12 root root     0 Feb  9 21:26 sys/
drwxrwxrwt   5 root staff  280 Feb  9 21:34 tmp/
drwxr-xr-x   7 root root   140 Mar 22  2018 usr/
drwxrwxr-x   8 root staff  180 Jan 20 15:27 var/
tc@box:/$
tc@box:/$ touch /etc/testfile
tc@box:/$
tc@box:/$ echo "MytestFileScript" > /etc/testfile
tc@box:/$
tc@box:/$ cat /etc/testfile
MytestFileScript
tc@box:/$
Notice from a fresh boot my /etc directory is owned by user & group "tc:staff"  therefore I shouldn't need elevated privileges to create and write to a file within it.
To confirm this I was able to create a file and edit it with only user privileges (see above).

So what error messages are you getting when you attempt to edit the file?


Maybe you're trying to edit the symlink?  whenever you come across this issue try instead to open the configuration file and saveas lighttpd.conf   then edit it and make a backup.
alternatively saveas a new file temporarily, delete the existing file and rename the new file same as per the old symlink and make a backup when editing is complete.
I'm not saying you can't do this any other way am just saying this is the right way to accomplish the task.


The TinyCore way is to create a configuration file and add it to your backup, or create an extension install into the file system all of your configuration files.  It's really no big issue when you know how.

Good luck

It's not really an obsession.  Frankly, I could do without it.  But it is necessary to start the server as Root in order for it to use ports under 1024 (specifically 80 and 443, which are defaults expected by other applications).  And this limits the ways in which lighty can be implemented.  For reasons of security it is not desirable to operate the Server as root, yet it must be launched as root in order to access those ports.

I definitely made a lot of mistakes along the way, but this was me trying to answer various unanswered questions and create a breadcrumb trail through my various blunders.  Let's not forget the first reply: "I don’t use lighttpd so am not really qualified to answer this, ..."

One of the mistakes was probably making a Dir as root when I should not have.  That said, I am using spacefm to navigate and editing with leafpad.  Neither of these are 'playing nice' with '/etc' or its subdirs.  Troubleshooting that is beyond the scope of this thread, however.

Meanwhile, I have learned a great deal about both TC and lighty and how to deploy it in a way which  follows conventional wisdom of which I was previously unaware.

After learning, testing and a lot of redoing I currently have lighty loading with SSL before the desktop or the browser, which is what I needed to happen. I still need to get PHP, Ruby and a couple of other things going before I'm ready for prime time, but when I get a moment I'll post an update on how I managed to make this work.