WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: (solved): Trying to setup Web Server using Lighttpd - 3.7 TC Live CD to test  (Read 6461 times)

Offline zatman

  • Newbie
  • *
  • Posts: 18
Hi All:

I have been trying to setup Lighttpd (ver. # 1.4.28) for some time, and no luck.  I have done my best to research and feel I am doing things correctly.  So my problem might be an odd one and hope somebody can help.

I am doing this command to test my lighttpd.conf:

lighttpd -t -f lighttpd.conf

It should be known, that my config file is in the directory to which I am doing this command.  The response I get back is below.

(configfile.c.853) source: lighttpd.conf line: 2 pos: 7 invalid character in variable name
(configfile.c.909) configfile parser failed at: =

My lighttpd.conf is below.

# Start Lighttpd
HTTPD=/usr/local/sbin/lighttpd
HTTPD_ROOT=/mnt/hda1/www
HTTPD_CONF=$HTTPD_ROOT/lighttpd.conf
cat << EOF > $HTTPD_CONF
mimetype.assign = (".html" => "text/html")
server.document-root = "/htdocs"
server.port = 80
server.username = "nobody"
server.groupname = "nogroup"
server.chroot = "$HTTPD_ROOT"
EOF
exec $HTTPD -f $HTTPD_CONF &>/dev/null

This config is one I found in another forum entry that was stated does work.

(see link - http://forum.tinycorelinux.net/index.php/topic,10999.0.html )

Now the error says "line: 2 pos: 7" - Which seems to be the forward slash.  So as a guess, I put the following in quotes -  "/usr/local/sbin/lighttpd" - to see if that might help.

Saved my config and tested it again.

lighttpd -t -f lighttpd.conf

I still had an error (on the 3rd line) this time it was the forward slash in the - /mnt/hda1/www

I also put that in "/mnt/hda1/www" - saved my config and tested again.

Still another error (4th line) - Now it does not seem to like the $ - in $HTTPD_ROOT/lighttpd.conf.

I did not go any further...
---------------------------------------------------------------------------------------------------------------------------------

So all of this seems odd, since nobody else has had this issues before.  Are these issues because I am running this in TC 3.7 LIVE CD?  Has anybody tried this before?  I wanted to play with this web server (in a live CD) to see if I might want to use in another system.

Thanks

P.S. Not sure if this matters or not,  but I also installed lighttpd-webdav on this same TC 3.7 system.  I have not put that in my config yet. I like to make sure that I can get the basic web server functioning before adding other bells and whistles, but have not even got the basic running yet.

« Last Edit: September 08, 2011, 03:56:40 PM by zatman »

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Trying to setup Web Server using Lighttpd - 3.7 TC Live CD to test
« Reply #1 on: September 06, 2011, 06:12:43 PM »
Does HTTPD_ROOT environment variable exists?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Trying to setup Web Server using Lighttpd - 3.7 TC Live CD to test
« Reply #2 on: September 06, 2011, 07:54:20 PM »
zatman: My guess is that you misunderstood what was copied from the other thread to be an entire configuration file, but it appears to be rather a few commands that you could save into a file and call it a shell script.

Let me attempt to provide a break down of what those few lines are trying to achieve:
[1] Set up a few variables which define: (a) the path of the Lighttpd executable, (b) the directory containing the web root, and (c) the configuration file:
Code: (bash) [Select]
HTTPD=/usr/local/sbin/lighttpd
HTTPD_ROOT=/mnt/hda1/www
HTTPD_CONF=$HTTPD_ROOT/lighttpd.conf
[2] Creation of the configuration file by using the here document technique:
Code: (bash) [Select]
cat << EOF > $HTTPD_CONF
mimetype.assign = (".html" => "text/html")
server.document-root = "/htdocs"
server.port = 80
server.username = "nobody"
server.groupname = "nogroup"
server.chroot = "$HTTPD_ROOT"
EOF
[3] Start of the web server by making use of the previous two parts:
Code: (bash) [Select]
exec $HTTPD -f $HTTPD_CONF &> /dev/null
So the actual config file (i.e. '/mnt/hda1/www/lighttpd.conf' when using the definitions from part [1]) would just contain:
Code: [Select]
mimetype.assign = (".html" => "text/html")
server.document-root = "/htdocs"
server.port = 80
server.username = "nobody"
server.groupname = "nogroup"
server.chroot = "/mnt/hda1/www"
Please note that the contents of the last line depends on the setting for the web root and would need to fit with whatever you are using.

You could then run your test (i.e. lighttpd -tf /mnt/hda1/www/lighttpd.conf), but be aware that to run it proper (as part [3] from above would do) you'd require at least a 'htdocs' directory in the web root (due to the 'server.document-root' setting from part [2]), plus for all practical reasons at least a 'index.html' file in that directory as you would otherwise get a '404' error when connecting to the web server with any browser.

It might be also worth pointing out that if you save all three parts into a script file (e.g. 'start_lighttpd.sh') you'll need to run this as a super-user (e.g. via sudo sh start_lighttpd.sh) as only that way the server is able to bind to port 80. Likewise if you want to run in a non-daemon way you'd need to use something like sudo lighttpd -Df /mnt/hda1/www/lighttpd.conf

Offline zatman

  • Newbie
  • *
  • Posts: 18
Re: Trying to setup Web Server using Lighttpd - 3.7 TC Live CD to test
« Reply #3 on: September 07, 2011, 11:33:51 AM »
@ maro

Yes, you are correct, that I did not understand fully, what that other entry was stating.  Thanks for breaking down what that script was trying to do - create the lighttpd.conf. 

If I could trouble you further, and if you know lighttpd well enough,  could you answer some more basic questions.  If I do not use the script method to create my lighttpd.conf, could I just use one already created?  I will try to find a lighttpd.conf at the lighttpd web site.

Then I will repeat my test.

lighttpd -t -f lighttpd.conf

Do you know, when that is tested - how smart is this test?  Lets say I do not yet have my directory created for /mnt/hda1/www/htdocs.  Would this test report a missing directory?

If anybody has a very basic lighttpd.conf they would like to provide, that would be great.  I only need a very basic web server (at least to start).  Once I understand the basics, I feel confident that adding other things will be easy.

Thanks

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Trying to setup Web Server using Lighttpd - 3.7 TC Live CD to test
« Reply #4 on: September 07, 2011, 12:31:14 PM »
You can use an existing lighttpd.conf.
Just add it to /opt/.filetool.lst and do a backup.

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Trying to setup Web Server using Lighttpd - 3.7 TC Live CD to test
« Reply #5 on: September 07, 2011, 06:00:10 PM »
zatman: You wrongly assume that I know 'lighttpd'. That is not the case as yesterday might have been the first time I installed this extension to test out as I wrote my reply #2. But as I can recognise a shell script if I see one, it was easy enough to provide an answer.

From my (very limited) testing I got the impression that the '-t' option is basically a syntax test. IIRC there was no check that the directory defined by the combination of 'server.chroot' and 'server.document-root' does indeed exist.

BTW, if you want to test stuff and are apprehensive to put any "real" system in danger I'd highly recommend to use virtual machines (e.g. using QEMU or VirtualBox). That is at least what I do several times every day as a means to have a completely "safe" testing ground. For example for yesterday's test I used: mkdir -p /tmp/www/htdocs and then used HTTPD_ROOT=/tmp/www instead. With this little adjustment (and replacing other occurrences of '/mnt/hda1' with '/tmp' accordingly) I managed to "discover" all what I wrote. Plus I had to install a browser (e.g. by using the 'opera.tcz' extension) for a bit of a test run, and I used 'lighttpd -D -f ...' as with this '-D' option one gets to see log messages more directly.

Offline zatman

  • Newbie
  • *
  • Posts: 18
(solved): Trying to setup Web Server using Lighttpd - 3.7 TC Live CD to test
« Reply #6 on: September 08, 2011, 03:43:38 PM »
@ maro and others

Thanks for all who replied.

Ok, I found a very basic lighttpd.conf, and used it.  What do you know,  it WORKED!  Still playing with it, but seems to do most of what I need.  Oh, I did change over to using the /tmp folder, should have changed that in my prior entry.  But at the time, did not now if lighttpd needed to see an /mnt folder.

I been researching how to use QEMU and Virt-box.  This is my next task, I want to take on.  But need to buy some more memory for my older systems (like an ATOM - small CPU and low power use).  So my current restrictions are limited to what computers I would like to use for this testing, and not fearing to use 'real' systems.  Any ways, its all good.  :)

So I guess this forum entry could be closed/solved. 

Thanks.
« Last Edit: September 08, 2011, 03:55:33 PM by zatman »