We often recommend to set lighttpd in front of apache to handle http requests (more about https://www.percona.com/blog/speedup-your-lamp-stack-with-lighttpd/ ) , redirect dynamic requests to apache and handle static files by itself. I just gathered step-by-step instruction how to do that in 10 minutes, as it may be not so obvious.
|
1 |
yum install pcre-devel |
|
1 |
lighttpd-1.4.XX/doc/lighttpd.conf |
|
1 |
/etc/lighttpd/lighttpd.conf |
|
1 |
/var/log/lighttpd |
|
1 |
server.document-root = "/www/html/htdocs" |
|
1 |
server.modules = (<br>...<br> "mod_auth",<br> "mod_status", <br> "mod_proxy",<br>...<br>)<br> |
|
1 |
status.status-url = "/server-status" |
|
1 |
auth.backend = "htpasswd"<br>auth.backend.htpasswd.userfile = "/var/www/.htpasswd"<br><br>auth.require = ( "/server-status" =><br> (<br> "method" => "basic",<br> "realm" => "status",<br> "require" => "valid-user"<br> )<br>)<br> |
|
1 |
Listen |
|
1 |
VirtualHost |
|
1 |
KeepAlive Off |
|
1 |
$HTTP["url"] !~ ".(js|css|gif|jpg|png|ico|txt|swf|html|htm)$" {<br> proxy.server = ( "" => (<br> ( "host" => "127.0.0.1", "port" => 8080 )<br> )<br> )<br>}<br> |
|
1 |
js|css|gif|jpg|png|ico|txt|swf|html|htm |
|
1 |
cp /doc/rc.lighttpd.redhat /etc/init.d/lighttpd |
|
1 |
lighttpd="/usr/local/lighttpd/sbin/lighttpd" |
|
1 |
chkconfig --add lighttpd<br>chkconfig --level 2345 lighttpd on |
That’s all. For complex apache setups and VirtualHosts it may be trickier, but work just fine for simple cases.
Resources
RELATED POSTS