Recommendation for multiple sites with lighttpd

Hi!

I'm running several sites on my Linode with lighttpd, most of them hosting simple wordpress-esque stuff with low load and one fairly high-load site. Until now, all sites were running under a single lighttpd process as virtual hosts, which made configuration easy.

Now I'm beginning to set up a new site which will hopefully be relatively busy as well. I'm not sure how I'm going to monitor each site individually with all of them using the same php-cgi. On my old host (dreamhost, ugh), the managed lighttpd was set up to run one proxy process and several lighttpd processes with php children attached to each one individually. This was practical for monitoring the sites seperately but seems to be a waste of resources and a pain in the ass to set up (seperate XCache, individual php.inis, the necessity of setting up a proxy, etc…)

So my question(s) is:

What do you do on your servers? Do you run multiple processes? Multiple Linodes? If yes, what method do you use to avoid doing twice the maintenance work?

Thanks in advance!

5 Replies

I use one lighttpd process with virtualhosts, of course. It's silly to duplicate software/hardware just to get different log files; there are ways do do that with a single lighttpd process.

In my case, I "don't care", so everything goes into one log file. If I needed to see information for one specific domain, then it's pretty simple to just write a quick script to grab only for one domain.

It's not so much about the log files but more about monitoring memory usage and scripts that go berserk. If there are changes on both sites that could affect memory usage, how do I figure out which one is causing the trouble?

For privilege separation and isolation reasons, I run one lighttpd and a php-cgi for each different subsystem (currently 3 on my Linode 360) that uses PHP. I keep the -C (children) option tuned relatively low, and in my situation, all three of the subsystems are completely unique so I'm not "wasting" that much from xcache duplication.

Here's one of my "almost 100% idle" handlers:

$ cat /etc/event.d/fcgi-asterisk 
# spawns fcgi handler

start on startfcgi
stop on stopped lighttpd
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

pre-start exec sleep 5

respawn
exec /usr/bin/spawn-fcgi -n -f /usr/bin/php-cgi -a 127.0.0.1 -p 4001 -C 2 -u asterisk -g asterisk

For b2evolution and gallery2, I have -C 4. Of course, the -p, -u, and -g are different for each.

This results in:

blogs    24634  0.0  0.0  38496   336 ?        Ss    2009   0:00 /usr/bin/php-cgi
blogs    26781  0.0  3.8  43724 13584 ?        S    Jan28   0:19  \_ /usr/bin/php-cgi
blogs    23116  0.0  3.7  42848 13328 ?        S    09:42   0:06  \_ /usr/bin/php-cgi
blogs    27015  0.0  3.9  43480 14176 ?        S    10:20   0:06  \_ /usr/bin/php-cgi
blogs    22731  0.0  3.0  40868 10880 ?        S    14:43   0:01  \_ /usr/bin/php-cgi
asterisk 24635  0.0  0.0  38496   268 ?        Ss    2009   0:00 /usr/bin/php-cgi
asterisk 24640  0.0  3.3  42428 11888 ?        S     2009   0:02  \_ /usr/bin/php-cgi
asterisk 24642  0.0  2.8  41272 10216 ?        S     2009   0:01  \_ /usr/bin/php-cgi
gallery2 24636  0.0  0.1  38496   372 ?        Ss    2009   0:00 /usr/bin/php-cgi
gallery2  4453  0.0  5.4  43224 19300 ?        S    06:46   0:05  \_ /usr/bin/php-cgi
gallery2  4972  0.0  5.1  41816 18520 ?        S    06:50   0:06  \_ /usr/bin/php-cgi
gallery2  7655  0.0  4.8  41552 17232 ?        S    07:20   0:05  \_ /usr/bin/php-cgi
gallery2 10281  0.0  5.0  41528 17892 ?        S    07:41   0:05  \_ /usr/bin/php-cgi

             total       used       free     shared    buffers     cached
Mem:           348        323         24          0         57         98
-/+ buffers/cache:        167        180
Swap:          255        122        133

… which ain't too bad. IMHO, one of the major advantages of doing the lighttpd/fcgi method is being able to run php scripts on different uids, so you might as well do it. :-)

Ah, that's what I was looking for, thanks! Event with fancy upstart support :-)

When I last used spawn-fcgi, it still had problems with leaking that are rumored to be gone. Do you do scheduled restarts of spawn-fcgi? lighttpd seems to be doing this on its own for the "built-in" php handler.

Nope, I do nothing special. This is the stock Ubuntu 8.04 kit, and I haven't noticed any memory leakage or other weird issues. Maybe it's Wordpress ;-)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct