LinHES Forums
http://forum.linhes.org/

Replace Apache with Lighttpd
http://forum.linhes.org/viewtopic.php?f=3&t=7511
Page 1 of 2

Author:  Protoss [ Sat Dec 24, 2005 5:30 pm ]
Post subject:  Replace Apache with Lighttpd

I run a webserver using Lighttpd, and it seems to run a lot faster than Apache, especially at lightweight jobs, like MythWeb. So I decided to replace the bloated Apache with the super-fast Lighttpd. It is a very simple process, and takes only a few steps, so here it goes...
Quote:
1. Download the package (wget http://t0z.org/debian/lighttpd_1.4.8-1_i386.deb)
2. Install it (dpkg -i lighttpd_1.4.8-1_i386.deb)
3. Kill Apache so Lighttpd can have port 80. (/etc/init.d/apache stop)
4. Start Lighttpd to make sure everything is good. (/etc/init.d/lighttpd start)
5. If you can see the MythWeb main page, everything is good, so you can continue onward!
6. Now since Lighttpd uses FastCGI to communicate with PHP, we need to recompile PHP from the source so....
7. Download PHP (wget http://us3.php.net/get/php-4.4.1.tar.gz ... his/mirror)
8. Untar PHP (tar zxvf php-4.4.1.tar.gz)
9. Now for the fun of compiling from the source! (cd ./php-4.4.1/)
10. Compile PHP with FastCGI support (./configure --enable-fastcgi --enable-force-cgi-redirect --with-gd --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-freetype-dir=/usr/lib --with-zlib-dir=/usr/lib) Then (make) and finally (make install)
11. See if PHP compiled right (php -v) It should say
Code:
PHP 4.4.1 (cgi-fcgi) (built: Dec 24 2005 16:47:23)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

12. Now that we have PHP with FastCGI working, we have to configure Lighttpd to use it. (mcedit /etc/lighttpd/lighttpd.conf and find where it says
Code:
##fastcgi module
, now uncomment everything in that section, as the defaults should fit this install) In the beginning of the file, you will have to also uncomment "mod_fastcgi".
13. Restart Lighttpd (/etc/init.d/lighttpd restart) and if it doesn't spit out any errors, you are now good to go!

That should be it, you have a barebones working Lighttpd webserver. More information on all the modules included with Lighttpd can be found at their site here. Please tell me if anything is wrong in the guide, its my first HowTo...

Author:  cesman [ Sat Dec 24, 2005 5:51 pm ]
Post subject: 

Nice!

Author:  MisoSoup777 [ Sat Dec 24, 2005 8:43 pm ]
Post subject: 

Excellent. Just did this in about 15 minutes. The only thing I would add was that I had to uncomment the line in /etc/lighttpd/lighttpd.conf:

server.modules = (

"mod_fastcgi",

In order to get it to use fcgi.

Nice work.

Author:  Dale [ Sun Jan 01, 2006 4:06 pm ]
Post subject: 

Cesman, this would be a "good thing" to do by default to begin an effort to reduce the size needed for KnoppMyth. What are your thoughts on this? I mean, you really don't have that much to do on keeping up with KnoppMyth, after all. :D

Author:  benjohnson [ Mon Jan 02, 2006 1:11 pm ]
Post subject: 

1) don't forget
Code:
update-rc.d -f apache remove

so apache doesn't restart on reboot

Otherwise great job! Mythweb is sooo much more responsive now

Author:  cesman [ Mon Jan 02, 2006 10:15 pm ]
Post subject: 

Dale wrote:
Cesman, this would be a "good thing" to do by default to begin an effort to reduce the size needed for KnoppMyth.
Perhaps, but mostly likely post-R5.

Author:  prosonik [ Tue Jan 03, 2006 1:02 am ]
Post subject:  High CPU?

Hi,

I just got done with the switchover, and it seems to out peform apache. However, I noticed that the cpu usauge spiked to 54% on refresh, causing my front-end to 'burp'.. Anybody else notice this? Other then that, the guide was perfect line-by line. Well done.

prosonik

Author:  Protoss [ Tue Jan 03, 2006 4:46 pm ]
Post subject: 

I'll look at the mailing lists and forums to see if this is a problem with my guide, or with lighttpd. And thnx for the comments...at least I'm good for something around here :P

Author:  iscraigh [ Sat Jan 14, 2006 10:54 pm ]
Post subject: 

Followed the directions get know errors php -v looks like yours, lighttpd starts without errors but........The mythweb start page comes up but the listings page does not. I am running r5a26. Could some one point me in the right direction to figure this out.

Thanks

Craig

Author:  iscraigh [ Sat Jan 14, 2006 11:11 pm ]
Post subject: 

Never mind for now I am tired and in the mythtv menu I pressed restore not restart. Now the frontend won't start so I am just going to do the upgrade to r5a31 then I will try this again. I have a feature request how about a box that pops up when you press restore that says "hey stupid are you sure you want to do this" lol


Craig

Author:  tjc [ Sun Jan 15, 2006 12:11 am ]
Post subject: 

iscraigh wrote:
Never mind for now I am tired and in the mythtv menu I pressed restore not restart. Now the frontend won't start so I am just going to do the upgrade to r5a31 then I will try this again. I have a feature request how about a box that pops up when you press restore that says "hey stupid are you sure you want to do this" lol

There's actually a well documented tweak for that. Hang on and I'll see if I can find the thread... Ah, here it is: http://mysettopbox.tv/phpBB2/viewtopic.php?t=3959& you want the XML changes from khrusher's post about 8 or 9 down... I think someone else even had a script that asked "Are you sure?"

Author:  iscraigh [ Tue Jan 17, 2006 10:25 pm ]
Post subject: 

Okay I loaded R5A30.1 and once getting it running I thought I would try this. Everthing went fine but I do get these two errors.

Warning at /usr/share/mythtv/mythweb/includes/init.php, line 151:
unlink(image_cache/2031_20060107223000_20060107230000.nuv.png): Operation not permitted

Warning at /usr/share/mythtv/mythweb/themes/Default/theme.php, line 16:
Cannot modify header information - headers already sent by (output started at /usr/share/mythtv/mythweb/includes/errors.php:68)

Any suggestions as to how I can track this down would be appreciated.


Mythweb does seem faster; I recommend this switch.


Craig

Author:  iscraigh [ Wed Jan 25, 2006 12:45 am ]
Post subject: 

this was not a lighttpd error it happened when I switched back to apache. I solved it by deleting the images from the image_cache folder that were owned by root.

Problem has not returned and I am happy with the performance of lighttpd

Craig

Author:  mapper [ Sun Feb 19, 2006 11:55 am ]
Post subject: 

And to keep your http://mythtv/mythweb access secure as with your old .htaccess file and Apache setup, just follow these instructions: http://forum.lighttpd.net/topic/203#581

Edit /etc/lighttpd/lighttpd.conf and:

1- Uncomment the mod_auth line (remove the "#" sign)

Code:
#                                "mod_auth",


2- Add the following lines

Code:
# Allow HTACCESS for Mythtv
auth.backend           = "htpasswd"
auth.backend.htpasswd.userfile  = "/etc/apache/basicauth"
auth.require             = ( "/mythweb/" =>
                                    ( "method" => "basic",
                                      "realm" => "MythTV",
                                      "require" => "valid-user"
                                    )
                                  )


3- Save lighttpd.conf

Then restart the lighttpd server:

Code:
root@mythtv: /etc/init.d/lighttpd restart


Now load http://mythtv/mythweb/ in your favorite browser and you should get a login pop-up, the same as you used to get when running mythweb on Apache with the .htaccess file setup!

Mapper

Author:  huntermcdole [ Wed Mar 22, 2006 10:35 pm ]
Post subject: 

When I tried this I ened up with this when I accessed mythweb, any idea of why? my php -v came out exactly as the posted one. Using knoppmyth R5B7


Database Setup Error

The database environment variables are not correctly set in the
included .htaccess file. Please read through the comments included
in the file and set up the db_* environment variables correctly.

Some possible solutions are to make sure that mod_env is enabled
in httpd.conf, as well as having followed the instructions in the
README about the AllowOverride settings.

Page 1 of 2 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/