Lighttpd is a fast and secure web-server which has been optimized for high-performance environments. The server has a very low memory footprint compared to other webservers and takes care of cpu-load. It includes the following advanced features:
CentOS turn on EPEL repo
The lighttpd server is not part of default CentOS or RHEL based system. To install lighttpd using theyum command, first grab the latest epel release file, enter: --2014-02-23 12:24:52-- http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm Resolving epel.mirror.net.in... 120.88.47.14, 2401:4800:2121:c0:ff:ee:ee:2 Connecting to epel.mirror.net.in|120.88.47.14|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 14540 (14K) [application/x-redhat-package-manager] Saving to: “epel-release-6-8.noarch.rpm” 100%[==========================================================================================>] 14,540 54.6K/s in 0.3s 2014-02-23 12:24:53 (54.6 KB/s) - “epel-release-6-8.noarch.rpm” saved [14540/14540]
Use rpm command to install downloaded epel-release-6-8.noarch.rpm file, type: warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ########################################### [100%] 1:epel-release ########################################### [100%] CentOS Linux install Lighttpd web-server
Type the followingyum command: Loaded plugins: downloadonly, fastestmirror, security Loading mirror speeds from cached hostfile * base: mirror.thelinuxfix.com * epel: mirror.steadfast.net * extras: holmes.umflint.edu * updates: bay.uchicago.edu Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package lighttpd.x86_64 0:1.4.34-1.el6 will be installed ---> Package lighttpd-fastcgi.x86_64 0:1.4.34-1.el6 will be installed --> Processing Dependency: spawn-fcgi for package: lighttpd-fastcgi-1.4.34-1.el6.x86_64 ---> Package lighttpd-mod_geoip.x86_64 0:1.4.34-1.el6 will be installed --> Processing Dependency: libGeoIP.so.1()(64bit) for package: lighttpd-mod_geoip-1.4.34-1.el6.x86_64 --> Running transaction check ---> Package GeoIP.x86_64 0:1.4.8-1.el6 will be installed ---> Package spawn-fcgi.x86_64 0:1.6.3-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================== Package Arch Version Repository Size ====================================================================== Installing: lighttpd x86_64 1.4.34-1.el6 epel 294 k lighttpd-fastcgi x86_64 1.4.34-1.el6 epel 44 k lighttpd-mod_geoip x86_64 1.4.34-1.el6 epel 21 k Installing for dependencies: GeoIP x86_64 1.4.8-1.el6 epel 620 k spawn-fcgi x86_64 1.6.3-1.el6 epel 16 k Transaction Summary ====================================================================== Install 5 Package(s) Total download size: 995 k Installed size: 2.4 M Is this ok [y/N]: y Downloading Packages: (1/5): GeoIP-1.4.8-1.el6.x86_64.rpm | 620 kB 00:00 (2/5): lighttpd-1.4.34-1.el6.x86_64.rpm | 294 kB 00:00 (3/5): lighttpd-fastcgi-1.4.34-1.el6.x86_64.rp | 44 kB 00:00 (4/5): lighttpd-mod_geoip-1.4.34-1.el6.x86_64. | 21 kB 00:00 (5/5): spawn-fcgi-1.6.3-1.el6.x86_64.rpm | 16 kB 00:00 ---------------------------------------------------------------------- Total 1.7 MB/s | 995 kB 00:00 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 Importing GPG key 0x0608B895: Userid : EPEL (6) <epel@fedoraproject.org> Package: epel-release-6-8.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 Is this ok [y/N]: y Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : lighttpd-1.4.34-1.el6.x86_64 1/5 Installing : GeoIP-1.4.8-1.el6.x86_64 2/5 Installing : spawn-fcgi-1.6.3-1.el6.x86_64 3/5 Installing : lighttpd-fastcgi-1.4.34-1.el6.x86_64 4/5 Installing : lighttpd-mod_geoip-1.4.34-1.el6.x86_64 5/5 Verifying : lighttpd-1.4.34-1.el6.x86_64 1/5 Verifying : lighttpd-mod_geoip-1.4.34-1.el6.x86_64 2/5 Verifying : spawn-fcgi-1.6.3-1.el6.x86_64 3/5 Verifying : GeoIP-1.4.8-1.el6.x86_64 4/5 Verifying : lighttpd-fastcgi-1.4.34-1.el6.x86_64 5/5 Installed: lighttpd.x86_64 0:1.4.34-1.el6 lighttpd-fastcgi.x86_64 0:1.4.34-1.el6 lighttpd-mod_geoip.x86_64 0:1.4.34-1.el6 Dependency Installed: GeoIP.x86_64 0:1.4.8-1.el6 spawn-fcgi.x86_64 0:1.6.3-1.el6 Complete!
Turn on lighttpd server on a CentOS Linux for the first time, enter: CentOS Linux install PHP
Type the followingyum commandto install php5.x and related modules on a CentOS Linux: CentOS Linux install MySQL database server
Type the following command to install mysql database server on a CentOS Linux based system usingyum command: CentOS Linux Lighttpd web-server configuration
Configure lighttpd
Edit /etc/lighttpd/lighttpd.conf, enter: Setting server rootSet it as follows to protect server root: var.server_root = "/var/www" Load the modulesUncomment the following line: include "modules.conf" Set server port to 80server.port = 80 Bind to a specific IP called 1.2.3.4Set the following to your web-server public ip such as 1.2.3.4: server.bind = "1.2.3.4" Set document rootYou are going to store html/images/js/php files in server_root + "/lighttpd" i.e. /var/www/lighttpd/ directory: server.document-root = server_root + "/lighttpd" Hide/set server tagSet server name or hide it: server.tag = "nixCraft-Web-Server" Save and close the file. Configure lighttpd modules
Edit /etc/lighttpd/modules.conf, enter:
Configure php as fastcgiUncomment the following FastCGI (mod_fastcgi) line for php: include "conf.d/fastcgi.conf" Also make sure following is uncommted as per requirement : server.modules = ( "mod_access", "mod_alias", "mod_auth", # "mod_evasive", "mod_redirect", "mod_rewrite", # "mod_setenv", # "mod_usertrack", ) Configure php5
Edit /etc/lighttpd/conf.d/fastcgi.conf file, type: ## small server config ## ## For a large server set max-procs, PHP_FCGI_CHILDREN, and PHP_FCGI_MAX_REQUESTS as per your setup ## server.modules += ( "mod_fastcgi" ) fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php-cgi", "socket" => "/tmp/php-cgi.socket." + var.PID, "max-procs" => 1, "idle-timeout" => 30, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "1", "PHP_FCGI_MAX_REQUESTS" => "50" ), "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), "broken-scriptfilename" => "enable" )) ) Save and close the file.
Restart the lighttpd
Type the following command to restart lighttpd server on a CentOS Linux :
Verify that everything is working
Make sure port 80 is opened and owned by lighttpd: tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 29085/lighttpd
Make sure no errors were reported in log file: 2014-03-09 04:48:11: (server.c.1241) logfiles cycled UID = 0 PID = 30314 2014-03-09 10:54:27: (server.c.1557) server stopped by UID = 0 PID = 4680 2014-03-09 10:54:28: (log.c.166) server started Test it
Create a hello.php in /var/www/lighttpd/ directory: <html> <head> <title>Hello - Lighttpd - PHP - nixCraft - Test</title> </head> <body> <h1>Hosshin - Zen monk</h1> Zen monk poem: <?php $zen_poem = '<blockquote><em>'; $zen_poem .= "Coming, all is clear,<br>"; $zen_poem .= "no doubt about it.<br>"; $zen_poem .= "Going, all is clear,<br>"; $zen_poem .= "without a doubt.<br>"; $zen_poem .= "What, then, is it all?"; $zen_poem .= "</em></blockquote>"; echo $zen_poem; ?> <hr> <h1>PHPINFO</h1> <?php phpinfo(); ?> <hr> <center><small>© nixCraft</small></center> </body> </html> Fire a web-browser and type url: http://your-server-ip/hello.php http://server1.cyberciti.biz/hello.php Fig. 01: PHP in action on a CentOS Lighttpd based server
See also And there you have it, the lighttpd+php+mysql configured on a CentOS Linux based server. I recommend that you read the following resource for more information:
http://www.cyberciti.biz/faq/centos-install-lighttpd-web-server-with-yum-command/ |