Go Back   vb.org Archive > Community Discussions > Forum and Server Management
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2006, 12:49 PM
rootnik rootnik is offline
 
Join Date: Jun 2002
Posts: 173
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Tutorial: Use lighttpd to serve images

Lighttpd is a small web server that can serve static files faster than Apache. Some people are not comfortable, or just can't make a full switch to lighttpd. This tutorial will show you how to setup lighttpd to serve your images while allowing Apache to continue taking care of everything else.


I am not going to go into detail on why or how it can do this. Search google for lighttpd reviews and benchmarks for more information.

1. install lighttpd. Follow the guide here: http://trac.lighttpd.net/trac/wiki/TutorialInstallation

2. edit /etc/lighttpd/lighttpd.conf (you have moved this file here during installation, if you followed the guide linked above)

You want your lighttpd.conf to look something like this:

Code:
server.document-root = "/opt/httpd/htdocs/forums/images"

server.port = 2747
server.bind = "localhost"

mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png",
  ".gif" => "image/gif"
)
This is pretty straightforward.

Change server.document-root to the full path to your forum's images directory.
Change server.port to a non standard port. I used 2747 in the example above.

3. Open your apache config file (httpd.conf) and make sure the following modules are enabled:

Code:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
4. If you are NOT using virtual hosting, add this to the bottom of your httpd.conf:

Code:
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /forums/images http://localhost:2747/
ProxyPassReverse /forums/images http://localhost:2747/

If you ARE using virtual hosting, add the above to the <VirtualHost> tag that your forum site is in. This will either be in your httpd.conf, or a separate file such as httpd-vhosts.conf

And that is it!

Now, start light httpd with: /usr/local/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf

And reload apache.

Note: It is important to make sure that lighttpd starts before apache does so mod_proxy can do it's work. If you start apache first, and then lighttpd, you will get 404 errors for your images.
Reply With Quote
  #2  
Old 11-17-2006, 07:09 AM
orban orban is offline
 
Join Date: Jan 2005
Posts: 445
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is it worth proxying the requests through apache? O_o Doesn't that kinda defeat the point.
Reply With Quote
  #3  
Old 11-22-2006, 04:56 PM
jason|xoxide jason|xoxide is offline
 
Join Date: Jul 2006
Location: Exton, PA
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by orban View Post
Is it worth proxying the requests through apache? O_o Doesn't that kinda defeat the point.
I was wondering the same thing myself. I use lighttpd on my sites but I serve from a separate IP linked to images.whatever.com. I used to serve from the same IP but on a higher port (8080) but I had users complaining that the images were blocked when they were behind certain proxies or firewalls.
Reply With Quote
  #4  
Old 11-22-2006, 08:53 PM
orban orban is offline
 
Join Date: Jan 2005
Posts: 445
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah I guess subdomain if you want to run lighttpd/apache, but try to run lighttpd only...for the php too....
Reply With Quote
  #5  
Old 01-05-2007, 11:25 PM
pdatoon pdatoon is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for the tutorial. Do you need to change anything in your templates and styles?
Reply With Quote
  #6  
Old 01-09-2007, 03:25 PM
randominity randominity is offline
 
Join Date: Jul 2005
Location: Chicago, IL
Posts: 92
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by orban View Post
Is it worth proxying the requests through apache? O_o Doesn't that kinda defeat the point.
anyone have an answer to this? Was interested in either using lighty only or apache + lighty; don't have my new server to play with yet.
Reply With Quote
  #7  
Old 01-10-2007, 02:51 AM
pdatoon pdatoon is offline
 
Join Date: Nov 2001
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

noobie question. Do we have to change anything in the styles (like url) ?
Reply With Quote
  #8  
Old 01-10-2007, 05:54 AM
randominity randominity is offline
 
Join Date: Jul 2005
Location: Chicago, IL
Posts: 92
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by pdatoon View Post
noobie question. Do we have to change anything in the styles (like url) ?
doesn't look like it...

Code:
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /forums/images http://localhost:2747/
ProxyPassReverse /forums/images http://localhost:2747/
I think what this does is basically it will serve all requests that it get to /forum/images will go to localhost:2747 (assuming that's the port your lighttpd is running on)
Reply With Quote
  #9  
Old 02-02-2009, 01:05 PM
punchbowl punchbowl is offline
 
Join Date: Nov 2006
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd like to use it to serve images from /forum/albums*, /forum/customavatars, /forum/customprofilepics too - is that doable?

Also what format are album images stored in? looking at the dir I see "1631.picture" etc listed not 1631.jpg etc listed

Thanks in advance

--------------- Added [DATE]1233617274[/DATE] at [TIME]1233617274[/TIME] ---------------

I'm going to use:
Code:
server.document-root = "/opt/httpd/htdocs/forum/"
then
Code:
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /forum/images http://localhost/images:2747/
ProxyPassReverse /forum/images http://localhost/images:2747/

ProxyPass /forum/customavatars http://localhost/customavatars:2747/
ProxyPassReverse /forum/customavatars http://localhost/customavatars:2747/
see how it goes on my less busy board:erm:

I'll edit this again when I get it working properly
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:42 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04059 seconds
  • Memory Usage 2,244KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete