[http://www.lighttpd.net/ Lighttpd] is "a secure, fast, compliant, and very flexible [[Wikipedia:Web server|web-server]] that has been optimized for high-performance environments. It has a very low memory footprint compared to other webservers and takes care of cpu-load. Its advanced feature-set ([[Wikipedia:FastCGI|FastCGI]], [[Wikipedia:Common Gateway Interface|CGI]], Auth, Output-Compression, URL-Rewriting and many more) make lighttpd the perfect webserver-software for every server that suffers load problems."

[http://www.lighttpd.net/ Lighttpd] is "a secure, fast, compliant, and very flexible [[Wikipedia:Web server|web-server]] that has been optimized for high-performance environments. It has a very low memory footprint compared to other webservers and takes care of cpu-load. Its advanced feature-set ([[Wikipedia:FastCGI|FastCGI]], [[Wikipedia:Common Gateway Interface|CGI]], Auth, Output-Compression, URL-Rewriting and many more) make lighttpd the perfect webserver-software for every server that suffers load problems."

It may be necessary to add a user and group for {{ic|http}} if you do not already have one. That user needs to have write permissions to {{ic|/var/log/lighttpd}} as well, so we will make it the owner of the folder:

+

To test the install:

−

# groupadd http

+

# echo 'TestMe!' >> /srv/http/index.html

−

# adduser http

+

# chmod 755 /srv/http/index.html

−

# chown -R http /var/log/lighttpd

−

To test the install

+

To start the server:

−

# rc.d start lighttpd

+

# systemctl start lighttpd

−

# touch /srv/http/index.html

−

# chmod 755 /srv/http/index.html

−

# echo 'TestMe!' >> /srv/http/index.html

Then point your browser to {{ic|localhost}}, and you should see the test page.

Then point your browser to {{ic|localhost}}, and you should see the test page.

−

You may want to add lighttpd to the daemons list in {{ic|/etc/rc.conf}} to start the server on boot.

+

To start the server on every boot:

+

+

# systemctl enable lighttpd

Example configuration files are available in {{ic|/usr/share/doc/lighttpd/}}.

Example configuration files are available in {{ic|/usr/share/doc/lighttpd/}}.

+

+

===CGI===

+

+

CGI scripts work with Lighttpd out of box, you just need to enable the CGI module, include the configuration file and make sure your chosen programing language interpreter is installed. (ie for python you would install {{pkg|python}})

+

+

Create the file {{ic|/etc/lighttpd/conf.d/cgi.conf}} Add the following to it:

+

+

server.modules += ( "mod_cgi" )

+

+

cgi.assign = ( ".pl" => "/usr/bin/perl",

+

".cgi" => "/usr/bin/perl",

+

".rb" => "/usr/bin/ruby",

+

".erb" => "/usr/bin/eruby",

+

".py" => "/usr/bin/python",

+

".php" => "/usr/bin/php" )

+

+

index-file.names = ( "index.pl", "default.pl",

+

"index.rb", "default.rb",

+

"index.erb", "default.erb",

+

"index.py", "default.py",

+

"index.php", "default.php" )

+

+

For PHP scripts you will need to make sure the following is set in {{ic|/etc/php/php.ini}}

{{Note|If you receive errors like ''No input file found'' when attempting to access php files, there are several possible explanations. See [http://redmine.lighttpd.net/projects/1/wiki/frequentlyaskedquestions#I-get-the-error-No-input-file-specified-when-trying-to-use-PHP this FAQ] for more information.}}

−

include "conf.d/fastcgi.conf"

===== Using php-fpm =====

===== Using php-fpm =====

Line 114:

Line 158:

There is no adaptive spawning anymore in recent lighttpd releases. For dynamic management of PHP processes, you can use {{Pkg|php-fpm}}.

There is no adaptive spawning anymore in recent lighttpd releases. For dynamic management of PHP processes, you can use {{Pkg|php-fpm}}.

# pacman -S php-fpm

# pacman -S php-fpm

−

# rc.d start php-fpm

+

# systemctl enable php-fpm

−

{{Note|You can configure the number of servers in the pool and tweak other configuration options by editing the file {{ic|/etc/php/php-fpm.conf}}. More details on ''php-fpm'' can be found on the [http://php-fpm.anight.org/ php-fpm website]. You should also note that when you make changes to /etc/php/php.ini you will need to restart php-fpm}}

+

# systemctl start php-fpm

+

{{Note|You can configure the number of servers in the pool and tweak other configuration options by editing the file {{ic|/etc/php/php-fpm.conf}}. More details on ''php-fpm'' can be found on the [http://php-fpm.org/ php-fpm website]. You should also note that when you make changes to /etc/php/php.ini you will need to restart php-fpm}}

You should add "mod_redirect" in server.modules array in {{ic|/etc/lighttpd/lighttpd.conf}}:

You should add "mod_redirect" in server.modules array in {{ic|/etc/lighttpd/lighttpd.conf}}:

−

server.modules = (

+

server.modules += ( "mod_redirect" )

−

...

+

−

"mod_redirect",

−

...

−

)

−

$SERVER["socket"] == ":80" {

$SERVER["socket"] == ":80" {

$HTTP["host"] =~ "example.org" {

$HTTP["host"] =~ "example.org" {

Line 256:

Line 297:

}

}

}

}

−

+

$SERVER["socket"] == ":443" {

$SERVER["socket"] == ":443" {

ssl.engine = "enable"

ssl.engine = "enable"

Line 289:

Line 330:

Add following in {{ic|/etc/lighttpd/lighttpd.conf}}:

Add following in {{ic|/etc/lighttpd/lighttpd.conf}}:

include "conf.d/compress.conf"

include "conf.d/compress.conf"

−

{{Box Note | You can not do this (copy compress.conf) and add a needed content in {{ic|/etc/lighttpd/lighttpd.conf}} instead.}}

+

{{Note| You can not do this (copy compress.conf) and add a needed content in {{ic|/etc/lighttpd/lighttpd.conf}} instead.}}

==Troubleshooting==

==Troubleshooting==

Line 325:

Line 366:

".jpg" => "image/jpeg",

".jpg" => "image/jpeg",

".png" => "image/png",

".png" => "image/png",

−

".css" => "text/css"

+

".css" => "text/css",

+

"" => "application/octet-stream"

)

)

}}

}}

New lines are not needed and are only used here for readability.

New lines are not needed and are only used here for readability.

+

+

Note: The "application/octet-stream" declaration must be at the end. It is a catch-all, and any declarations after it will be ignored.

== See also ==

== See also ==

* [http://redmine.lighttpd.net/projects/lighttpd/wiki Lighttpd wiki]

* [http://redmine.lighttpd.net/projects/lighttpd/wiki Lighttpd wiki]

Revision as of 14:14, 6 December 2013

zh-CN:Lighttpdzh-TW:LighttpdLighttpd is "a secure, fast, compliant, and very flexible web-server that has been optimized for high-performance environments. It has a very low memory footprint compared to other webservers and takes care of cpu-load. Its advanced feature-set (FastCGI, CGI, Auth, Output-Compression, URL-Rewriting and many more) make lighttpd the perfect webserver-software for every server that suffers load problems."

Then point your browser to localhost, and you should see the test page.

To start the server on every boot:

# systemctl enable lighttpd

Example configuration files are available in /usr/share/doc/lighttpd/.

CGI

CGI scripts work with Lighttpd out of box, you just need to enable the CGI module, include the configuration file and make sure your chosen programing language interpreter is installed. (ie for python you would install python)

Create the file /etc/lighttpd/conf.d/cgi.conf Add the following to it:

Using php-fpm

Note: You can configure the number of servers in the pool and tweak other configuration options by editing the file /etc/php/php-fpm.conf. More details on php-fpm can be found on the php-fpm website. You should also note that when you make changes to /etc/php/php.ini you will need to restart php-fpm

Styles (CSS) not working properly

The default lighttpd config does not include a mimetype definition for CSS so when standards compliant browsers get text/html instead of text/css they get confused and nothing displays properly. To fix this add an entry for CSS.