Install Lighttpd in Linux

Source: Internet
Author: User
Tags fam

I. Why Lighttpd?
Isn't Apache acceptable?
When only static objects are supported, such as video clips and files,
Lighttpd is faster and more ideal

[The following four paragraphs are from: http://www.javayou.com/diary/3##]

Lighttpd is an open-source software led by Germans. Its fundamental goal is to provide a secure, fast, compatible, and flexible web server environment for high-performance websites. It features low memory overhead, low CPU usage, good performance, and rich modules.

Lighttpd is one of the many opensource lightweight Web servers. It supports important functions such as FastCGI, CGI, auth, output compress, URL rewriting, and alias. Apache is popular because of its rich functions, many functions of Lighttpd are implemented accordingly. This is very important for Apache users, because these problems must be addressed when migrating to Lighttpd.

In practical use, Lighttpd is indeed very good. The above mentioned Apache overload problem is completely solved using Lighttpd. The main problem with Apache is continuous fork () and switching under intensive concurrency, as well as high (relative to Lighttpd) memory usage, so that the system resources are exhausted. Lighttpd uses the multiplex technology, the code is optimized, the size is very small, the resource usage is very low, and the response speed is quite fast.

The rewrite Technology of Apache is used to hand over heavy cgi/FastCGI tasks to Lighttpd. Taking full advantage of both, the load on that server is now reduced by an order of magnitude, the response speed has also increased by one or even two orders of magnitude!

2. Where can I download Lighttpd?
Http://www.lighttpd.net
This is its official site.

I downloaded the lighttpd-1.4.19.tar.bz2 in the attachment.

  1. # Cp lighttpd-1.4.19.tar.bz2/usr/mylib \
  2. # Tar jxvf lighttpd-1.4.19.tar.bz2
  3. # Cd lighttpd-1.4.19
  4. #./Configure -- prefix =/usr/local/Lighttpd
  5. # Make
  6. # Make install
  7. OK!

However, I usually encounter problems in Step 4. I also encountered: Configure: Error: PCRE-config not found, install the PCRE-devel package and build with -- without-PCRE

In this case, you need to install a software package PCRE (Perl-Compatible Rule Expression Library), as shown in the following [the attachment also has]: http://sourceforge.net/project/showfiles.php? Group_id = 10194 & package_id = 9960 & release_id = 597811

After installation, compile Lighttpd. The process is described in step 6 above.

Iii. Post-compilation Configuration:

Cp doc/sysconfig. Lighttpd/etc/sysconfig/Lighttpd
Mkdir/etc/Lighttpd
Cp doc/Lighttpd. CONF/etc/Lighttpd. conf

If your Linux is RedHat, then:
Cp doc/rc. Lighttpd. RedHat/etc/init. d/Lighttpd

Modify/etc/init. d/Lighttpd and
Lighttpd = "/usr/sbin/Lighttpd"
Change
Lighttpd = "/usr/local/Lighttpd/sbin/Lighttpd"

This script is used to control the startup, shutdown, and restart of Lighttpd:
#/Etc/init. d/Lighttpd start

Startup error:
Start Lighttpd: 2008-08-06 12: 40: 28: (configfile. c.1136) Base-docroot doesn't exist:/srv/www/htdocs/

You need to modify the configuration in the/etc/Lighttpd. conf configuration file.
/Srv/www/htdocs/the path does not exist.
Server.doc ument-root = "/srv/www/htdocs /"
Change
Server.doc ument-root = "/var/www/htdocs /"
Try again
#/Etc/init. d/Lighttpd restart
Stop Lighttpd: [failed]
Start Lighttpd: 2008-08-06 12: 42: 27: (configfile. c.1136) Base-docroot doesn't exist:/var/www/htdocs/
2008-08-06 12: 42: 27: (server. c.591) setting default values failed
[Failed]

It turns out that the folder is not in # makedir/var/www/htdocs.
#/Etc/init. d/Lighttpd restart
Stop Lighttpd: [failed]
Start Lighttpd: [OK]

If you want to start Lighttpd when the server is started:
Chkconfig Lighttpd on

In this way, the Lighttpd is installed, and you need to configure Lighttpd.
See Lighttpd. conf configuration

Server. chroot
The root directory of the Web server when chroot is used to improve security. Recommended.

Server. Username = "..." server. groupname = "..."
Give up the root permission.

Dir-listing.activate
List directories if the index file is not found. Disable is recommended.

Server. Max-worker
By default, Lighttpd only starts one process, but also supports starting multiple processes like Apache. My experiment shows that starting multiple processes at the same time cannot improve the performance.

Server. Max-keep-alive-Requests
This is critical and has a significant impact on performance. Maximum number of requests that can be processed before a keep-alive session terminates the connection. Default: 128, which is not enough for a high-load application.

Server. Max-keep-alive-idle
The maximum number of seconds before an idle keep-alive connection is discarded. Default: 30.

Servers. Error-Handler-404
Processing When the page cannot be found does not affect the performance

Server. Max-FDS
Because Lighttpd is a single-threaded server, its main resource limit is the number of file descriptors. The default value is 1024. If you are on a high-load site, you may need to add the limit value through the following settings.
Server. Max-FDS = 2048, but this restriction takes effect only when Lighttpd is running as the root.

Connection. Kbytes-per-second, server. Kbytes-per-second
It is also worth mentioning that Lighttpd can limit the traffic of each connection or specific virtual machine.

Compress. cache-Dir, compress. filetype
If the text is slightly larger, you can use the compression algorithm to reduce bandwidth and improve efficiency. For example:
Compress. cache-Dir = "/var/Cache/Lighttpd/compress /"
Compress. filetype = ("text/plain", "text/html", "text/JavaScript", "text/CSS ")

Server. Stat-Cache-engine = "Fam"
This item can significantly improve the performance, Stat () cache. A stat call may be expensive. Set a cache to save time and avoid context switching. Replace Stat () every time to determine the existence of the file. It is only Stat () once, and then monitors the directory. If the directory remains unchanged, the files in it remain unchanged. Our memory file system does not need to be retained, depending on the situation.
Server. Stat-Cache-engine = "Fam" # Either fam, simple or disabled




Logs:

In Lighttpd, you can use the following configuration to implement an access log file every day.

Accesslog. filename = "|/usr/local/Lighttpd/bin/rotatelogs/usr/local/Lighttpd/logs/Access _ % Y % m % d. Log 86400"

Start:

#/Usr/local/Lighttpd/sbin/Lighttpd-F/etc/Lighttpd. conf
"-F is the startup parameter 』

Or:

#/Etc/init. d/Lighttpd start
〖Usage:/etc/init. d/Lighttpd [Start | stop | restart | condrestart | reload | status]

Or:

Service Lighttpd restart

 

Http://hi.baidu.com/619195553dream/blog/item/21e24e344ea99c97a8018e1e.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.