[personal profile] robinbobin
Часто плодятся httpd процессы, нагрузка на сервер из-за статичных документов
возрастает не по месяцам, а по дням и мешает динамическим документам быстрее
генерироваться. Знакомая картина?


Делаем следующее:

1. Скачиваем и устанавливаем lighttpd:
http://www.lighttpd.net/download/

        ./configure
        ./make all
        ./make install
        mkdir /etc/lighttpd
        cp ./doc/lighttpd.conf /etc/lighttpd/lighttpd.conf
        cp ./doc/rc.lighttpd.redhat /etc/init.d/lighttpd


2. Настраиваем по своему желанию /etc/lighttpd/lighttpd.conf.

3.В настройках /etc/lighttpd/lighttpd.conf:

        server.document.root=путь_к_www_вебсервера_apache
        server.port=81
        #Указываем запрещенные для чтения типы файлов,
        #чтобы посетители не смогли их видеть указав
        #domain.ru:81/файл
        url.access.deny=("~",".inc",".php",".htm",".html")
        #Также запрещаем листинг каталогов
        server.dir-listing="disable"
        
        
3. В корень www_вебсервера_apache в .htaccess добавляем:

        RewriteEngine on
        RewriteRule ^(.*.gif$) http://www.domain.ru:81/$1  [R]
        RewriteRule ^(.*.jpg$) http://www.domain.ru:81/$1  [R]  
        RewriteRule ^(.*.bmp$) http://www.domain.ru:81/$1  [R]  
        RewriteRule ^(.*.png$) http://www.domain.ru:81/$1  [R]  
        RewriteRule ^(.*.pdf$) http://www.domain.ru:81/$1  [R]  
        RewriteRule ^(.*.zip$) http://www.domain.ru:81/$1  [R]  
        RewriteRule ^(.*.rar$) http://www.domain.ru:81/$1  [R]  


где domain.ru - это Ваш домен

Всё, наслаждаемся разгрузкой Apache вебсервера, ведь теперь все типы
файлов, указанные в RewriteRule будут выдаваться не httpd, а lighttpd.

Для большей скорости можно также добавить в /etc/lighttpd/lighttpd.conf:

        server.max-worker=50
        server.max-keep-alive-requests=250
        server.max-keep-alive-idle=120
        server.max-read-idle =120
        server.protocol-http11 ="disable"


и включить mod_expire там же в server.modules, а затем указать:

        expire.url=("/" => "access plus 5 hours")



http://www.opennet.ru/base/net/apache_to_lighttpd.txt.html

Date: 2005-03-31 05:25 am (UTC)
From: [identity profile] xeonium.livejournal.com
nginx тоже рулит для статики, его юзает Rambler например.

Date: 2005-03-31 05:54 am (UTC)
From: [identity profile] whiskeydrinker.livejournal.com
pomoxlo? cool, molodetz, rubashku ostav' sebe :)

Profile

robinbobin

December 2016

S M T W T F S
     1 2 3
45 6 7 8 910
1112 13 14 15 16 17
18192021 22 23 24
25262728293031

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 6th, 2025 02:02 pm
Powered by Dreamwidth Studios