WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: lighttpd + php: It works, but why?  (Read 3437 times)

Offline stleric

  • Newbie
  • *
  • Posts: 21
lighttpd + php: It works, but why?
« on: November 14, 2012, 02:36:41 PM »
Hello,

Been messing around with lighttpd and php and while I did eventually manage to get it working I have questions about a few things.

Initially I installed just lighttpd, I set up my doc-root directory in /var/www/htdocs with the config file in /var/www/lighttpd.conf.  Chowned htdocs to nobody:nogroup, and used the .conf file that was suggested in the lighttpd 'info' panel.  That worked fine.

Then I loaded the php5 package, cribbing the conf entries from the php5 'info' panel.  In this case lighttpd wouldn't start complaining that it couldn't find the socket file '/tmp/php.socket-0'.  And, indeed, it seems no socket file gets created for some reason.  (I should mention that in all cases I invoked lighttpd via sudo).

What did finally work was setting up my doc-root in my home directory (/home, not /home/tc) and I used the .conf file that robc posted elsewhere in this forum.

My first question is why doesn't php work from the /var/www doc-root but it does from /home?

Secondly, it seems robc's config file does not use the server.username or server.groupname directives which means lighttpd not only starts up as root but continues to run as such.  Isn't that a no-no?

On xubuntu, lighttpd (+php) behaved more as I expected so I'm guessing there's something about TinyCore's operating environment that's causing these distortions?

In the TC environment I'm thinking there might be a small advantage to doc-rooting out of /home in that I don't have to fuss with the .filetool.lst file.  But if anyone has managed to get lighttpd+php to run "conventionally" (from /var/..., run as non-root) I'd like to hear how you did it.

TIA,
eric

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
Re: lighttpd + php: It works, but why?
« Reply #1 on: November 14, 2012, 04:51:36 PM »
I've not tried to use php or lighttpd on TC, but hopefully my answers can give you some ideas of issues to look at
My first question is why doesn't php work from the /var/www doc-root but it does from /home?
Did /var/www exist, and were the permissions sufficient for lighttpd to access the files?

Quote
Secondly, it seems robc's config file does not use the server.username or server.groupname directives which means lighttpd not only starts up as root but continues to run as such.  Isn't that a no-no?
Yes, this is a very bad idea. Of course, it's a simple thing to fix, and you generally shouldn't run scripts or configs you find online unless you understand what they're going to do.
Quote
On xubuntu, lighttpd (+php) behaved more as I expected so I'm guessing there's something about TinyCore's operating environment that's causing these distortions?
Ubuntu goes to a lot more effort to make the setup process as easy as possible. TinyCore's extensions are packaged by community members, and often (even if not deliberately) packaged to meet that community member's immediate needs. That might mean you need to spend a bit more time configuring and debugging than you are used to.

Quote
In the TC environment I'm thinking there might be a small advantage to doc-rooting out of /home in that I don't have to fuss with the .filetool.lst file.  But if anyone has managed to get lighttpd+php to run "conventionally" (from /var/..., run as non-root) I'd like to hear how you did it.
Are you particularly attached to lighttpd? Some time in the next week or two, I'll be doing some experiements with tinycore and nginx for a side project I'm considering. If there's interest, I'll document the relevant parts of the experience and post it on the forum.

Offline stleric

  • Newbie
  • *
  • Posts: 21
Re: lighttpd + php: It works, but why?
« Reply #2 on: November 14, 2012, 06:30:10 PM »
I've not tried to use php or lighttpd on TC, but hopefully my answers can give you some ideas of issues to look at
My first question is why doesn't php work from the /var/www doc-root but it does from /home?
Did /var/www exist, and were the permissions sufficient for lighttpd to access the files?
Var was there but I had to create www.  I'm fairly sure there was no permissions issue (I could see the index.html page).
Quote
Quote
Secondly, it seems robc's config file does not use the server.username or server.groupname directives which means lighttpd not only starts up as root but continues to run as such.  Isn't that a no-no?
Yes, this is a very bad idea. Of course, it's a simple thing to fix, and you generally shouldn't run scripts or configs you find online unless you understand what they're going to do.
Well, right now my choices are running and unsecure or secure and not running so I don't see anything simple about it, yet.
Quote
Quote
On xubuntu, lighttpd (+php) behaved more as I expected so I'm guessing there's something about TinyCore's operating environment that's causing these distortions?
Ubuntu goes to a lot more effort to make the setup process as easy as possible. TinyCore's extensions are packaged by community members, and often (even if not deliberately) packaged to meet that community member's immediate needs. That might mean you need to spend a bit more time configuring and debugging than you are used to.
I hadn't considered that.
Quote
Quote
In the TC environment I'm thinking there might be a small advantage to doc-rooting out of /home in that I don't have to fuss with the .filetool.lst file.  But if anyone has managed to get lighttpd+php to run "conventionally" (from /var/..., run as non-root) I'd like to hear how you did it.
Are you particularly attached to lighttpd? Some time in the next week or two, I'll be doing some experiements with tinycore and nginx for a side project I'm considering. If there's interest, I'll document the relevant parts of the experience and post it on the forum.
No, until a week ago I didn't know lighttpd existed.  I need something that works reasonably well with a PII w/ 128MB and doesn't chew up a lot of my time.  Let me go read up on nginx, I don't know what that is either.

thanks,
eric

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
Re: lighttpd + php: It works, but why?
« Reply #3 on: November 14, 2012, 07:25:11 PM »
Well, right now my choices are running and unsecure or secure and not running so I don't see anything simple about it, yet.
Sorry, I meant that it *should* be a simple thing to fix. I would try chowning your docroot to www-user:www-user, and set up lighttpd to use that (you might need to add the user first) instead of either root or nobody.

Quote
No, until a week ago I didn't know lighttpd existed.  I need something that works reasonably well with a PII w/ 128MB and doesn't chew up a lot of my time.  Let me go read up on nginx, I don't know what that is either.
nginx is another lightweight webserver, like lighttpd. I think it should run quite well on your hardware, although i haven't tested it on a system with less than 256 MB RAM.

Offline stleric

  • Newbie
  • *
  • Posts: 21
Re: lighttpd + php: It works, but why?
« Reply #4 on: November 14, 2012, 08:34:16 PM »
Well, right now my choices are running and unsecure or secure and not running so I don't see anything simple about it, yet.
Sorry, I meant that it *should* be a simple thing to fix. I would try chowning your docroot to www-user:www-user, and set up lighttpd to use that (you might need to add the user first) instead of either root or nobody.
Interesting suggestion, I'll try it tomorrow when I get in, but if it works I will just sh*t.

eric

Offline xyz-worx

  • Jr. Member
  • **
  • Posts: 69
Re: lighttpd + php: It works, but why?
« Reply #5 on: November 15, 2012, 12:58:19 AM »
Hi stleric,

if you are looking for a lightweight http-server just take a look at the monkey webserver

http://monkey-project.com/

I use it together with TLC (v3.8.4) on a similar 'old machine' with a low amount of ram.
The actual server's version is 1.1.1. It has a Fast-CGI interface and is widely configurable.
I think it's worth to take a look at it.

Regards
xyz-workx

Offline stleric

  • Newbie
  • *
  • Posts: 21
Re: lighttpd + php: It works, but why?
« Reply #6 on: November 15, 2012, 11:33:13 AM »
Well, how do you like that, it works now, as 'nobody'.  Robc's config file had a bunch of stuff that I thought was not necessary for my purposes, maybe something in there really is necessary.  Either that or maybe the problem was trying to operate from /var.  Well, more experimenting but at least now I have a working reference point.

Thanks for the nginx and monkey leads.

Offline stleric

  • Newbie
  • *
  • Posts: 21
Re: lighttpd + php: It works, but why?
« Reply #7 on: November 16, 2012, 02:56:43 PM »
One last thing.  Apparently, php-cgi needs to see libodbc.so.1 but it isn't there.  I had to create a link for it that points to libodbc.so.2.  The relevant maintainer may want to put the so.2 library in the package, have the relevant package install script create the link to .so.1 or make php-cgi less picky about which library it wants.

eric