BobCares :: Outsourced Web Hosting Support BobCares :: Outsourced Web Hosting Support   Call us Toll Free US: 1-602-288-9145
Toll Free: 1800-383-5193
Search site:

Contact us | Get custom quote
 
spacer.gif
spacer.gif  
4013 Reads
Add to Google AddThis Social Bookmark Button

LLMP Configuration

Posted on Sunday, March 25, 2007 - 02:41 AM
  spacer.gif
 
LLMP is a better LAMP . It is fast and stable. Lighty+php is 25% faster than Apache+mod_php . An LLMP server will provide 2 to 3 times faster than a LAMP. Lighttpd webserver is under BSD license so that you can configure it as you wish.

"Light is life,Lighty is Light,.....fly light"

1.1 What is Lighttpd?

Lighttpd ( Lighty or LightTPD) is a light weight webserver. It is faster than other webservers (like apache ,etc.,). So Lighty is very useful in high traffic servers.

1. Introduction

1.1 What is Lighttpd?
1.2. Features of Lighttpd.

2. What is LLMP (Linux + Lighttpd + Mysql +Php)

3. Install Lighttpd

3.1 Install open-ssl

4. Install Mysql

4.1 Using RPM
4.2 Using Source

5. Install Php

6. Conclusion

A. Acknowledgment

B. Downloads

C. References

D. Author

1.2. Features of Lighttpd

  • Modules support
  • Cache Meta Language
  • Virtual hosting
  • Minimal WebDAV support
  • Servlet (AJP) support (in versions 1.5.x and up)
  • Rule-based downloading
  • Server-side includes support
  • rrdtool statistics
  • chroot support
  • select()-/poll()-based web server
  • Authentication against a LDAP server
  • SSL support
  • Support for more efficient event notification schemes like kqueue and epoll
  • Conditional rewrites
  • Load-balancing FastCGI and SCGI support
  • lighttpd runs on GNU/Linux and other Unix-like operating systems and Microsoft Windows (with and without Cygwin).
  • Ruby on Rails and Lua communities.
  • Perl,Python,etc support
  • Secure
  • Speed
  • Compliance
  • Flexibility
  • Small memory footprint
  • Effective management of the cpu-load
  • Event-driven architecture supports for high performant AJAX applications

2. What is LLMP (Linux + Lighttpd + Mysql +Php)

LLMP ( Linux + Lighttpd +Mysql+PHP) is both a development and service environment same as LAMP(Linux +Apache+ Mysql+PHP) but with more performance and advantages than LAMP. Its configuration is very simple and can be used in live servers and local development environments.
From the following sections you can setup a general LLMP without much difficulty.
So let us start it now....

3. Install Lighttpd

In this section you can install and configure Lighty
# cd /usr/src/

# wget http://www.lighttpd.net/assets/2007/1/29/lighttpd-1.4.13.tar.gz

# tar -xvzf lighttpd-1.4.13.tar.gz

# cd lighttpd-1.4.13/

# ./configure --prefix=/usr/local/lighttpd --enable-fastcgi  --with-openssl

# make

# make install

# mkdir /etc/lighttpd

# cp -fr doc/lighttpd.conf /etc/lighttpd/
Now let us edit the configuration file of lighty " /etc/lighttpd/lighttpd.conf "
# pico /etc/lighttpd/lighttpd.conf
Add the following configurations.
server.modules (

		"mod_rewrite",

		"mod_auth",

		"mod_access",

		"mod_accesslog" 

		 )

server.document-root	= "/var/www/html/"

server.errorlog		= "/var/log/lighttpd.error.log"

accesslog.filename      = "/var/log/lighttpd.access.log"

server.port		= 80

server.bind		= "192.168.1.201"

server.pid-file         =  "/var/run/lighttpd.pid"

server.username		= "lighttpd"

server.groupname	= "lighttpd"
Here the ip "192.168.1.201" is my local ip ,so please change "server.bind" to your local ip and "server.port" to the port in which you wish to run lighty.
Now let us add a user to run lighty
# useradd lighthttpd

# groupadd lighthttpd
Now create the log files
# touch /var/log/lighttpd.error.log

# touch /var/log/lighttpd.access.log
Now change the ownerships
# chown lighthttpd.root /etc/lighttpd/lighttpd.conf

# chown -R lighttpd.lighttpd /var/www/html/

# chown lighttpd.lighttpd /var/log/lighttpd.error.log

# chown lighttpd.lighttpd /var/log/lighttpd.access.log
Now create our startup deamon script
# pico /etc/init.d/lighttpd
Add the following lines to this script
#!/bin/sh
# Source function library
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/lighttpd ]; then
        . /etc/sysconfig/lighttpd
fi

if [ -z "$LIGHTTPD_CONF_PATH" ]; then
        LIGHTTPD_CONF_PATH="/etc/lighttpd/lighttpd.conf"
fi

prog="lighttpd"
lighttpd="/usr/local/lighttpd/sbin/lighttpd"
RETVAL=0
start() {
        echo -n $"Starting $prog: "
        daemon $lighttpd -f $LIGHTTPD_CONF_PATH
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        killproc $lighttpd
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

reload() {
        echo -n $"Reloading $prog: "
        killproc $lighttpd -HUP
        RETVAL=$?
        echo
        return $RETVAL
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
       condrestart)
                if [ -f /var/lock/subsys/$prog ]; then
                        stop
                        start
                fi
                ;;
        reload)
                reload
                ;;
        status)
                status $lighttpd
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
                RETVAL=1
esac

exit $RETVAL
###########################################
Now give execute permission to this daemon script
# chmod 755 /etc/init.d/lighttpd
Let us start our Lighty as follows,before that all webservers listening to the port(server.port) must be stopped
# /etc/init.d/lighttpd start
Our Lighty is started and let us check it is listening port 80( or port mentioned in server.port).
# netstat -pant |grep lighttpd
 
Now we can create a test html file in the document-root.
# pico /var/www/html/index.html
Add the following lines to index.html.
Lighttpd is running......

Then call this file through the browser (with your Ip as configured in server.bind)as follows
http://192.168.1.201/
Note: If you use port other than 80 ,then you may need to mension that port in browser as http://192.168.1.201:port/
WOW lighty is working ..!!!
Let us add the following line to rc.local such that our server will be started during the boot time.
# echo "/etc/init.d/lighttpd start" >> /etc/rc.d/rc.local

The section " 3.1 " is for just a fun you can avoid this portion and continue with section " 4 "
The following steps ( in section 3.1 )will help you to install a self signed SSL certificate for your domain

3.1 Install open-ssl

Let us install an ssl for your domain as follows.
# mkdir /etc/lighttpd/ssl/yourdomain.com -p

# cd /etc/lighttpd/ssl/yourdomain.com
Now create SSl as follows. You need to provide information such as country name, your domain name etc.,
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
Let us give ownerships and permissions.
# chown lighttpd:lighttpd /etc/lighttpd/ssl -R

# chmod 0600 /etc/lighttpd/ssl/yourdomain.com
Now edit the lighty configuration to add ssl informations.
# pico /etc/lighttpd/lighttpd.conf
Add the following lines
$SERVER["socket"] == "192.168.1.201:443" {

server.document-root = "/var/www/yourdomain.com"

ssl.engine = "enable"

ssl.pemfile = "/etc/lighttpd/ssl/yourdomain.com/server.pem"

}
Please test the configuration as follows
# /usr/local/lighttpd/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf
Now create a documet-dir and a test index.html file
#mkdir /var/www/yourdomain.com/

# cd /var/www/yourdomain.com/

# pico index.html
Add the follwing lines to this index.html file
Light is runing in ssl...
Now give the ownerships
# chown -R lighttpd:lighttpd /var/www/yourdomain.com/
Let us restart our lighty
# /etc/init.d/lighttpd restart
Let us check lighty is listening on ssl port as follows
# /etc/init.d/lighttpd restart
My server given the following out put
# netstat -pant |grep lighttpd

tcp        0      0 192.168.1.201:443           0.0.0.0:*                   LISTEN      27948/lighttpd
tcp        0      0 192.168.1.201:80            0.0.0.0:*                   LISTEN      27948/lighttpd
You can access your secure site as follows
https://yourdomain.com/
So we successfully completed our lighty installation ......

4. Install Mysql

Let us install mysql. We can install mysql in two ways ,
1. By using an rpm ,or
2.From the source tar ball
The preferable method is by using an rpm ,because the up-gradation procedures are simple. Guys,like me,(who love and like linux) will prefer source installations. Any way the following section will tell you both of the procedures.

4.1 Using RPM

The rpm installations are simple.You can do it through yum.
# yum install mysql-server

# yum install mysql

# yum install mysql-devel

# yum install mysql-bench
Now installation is completed let us start mysql sever as follows
# /etc/init.d/mysqld start
Let us get the mysql prompt as follows.
 

# mysql
So the mysql rpm installations are finished.

4.2 Using Source

You can install mysql from source as follows
# cd /usr/local/

# wget http://downloads.mysql.com/archives/mysql-4.1/mysql-debug-4.1.21-pc-linux-gnu-i686-glibc23.tar.gz

# groupadd mysql

# useradd -g mysql mysql

# tar -xvzf mysql-debug-4.1.21-pc-linux-gnu-i686-glibc23.tar.gz

# ln -s /usr/local/mysql-debug-4.1.21-pc-linux-gnu-i686-glibc23 /usr/local/mysql

# cd mysql

# scripts/mysql_install_db --user=mysql

# chown -R root  .

# chown -R mysql data

# chgrp -R mysql .
Let us start mysql as follows,
# bin/mysqld_safe --user=mysql &
Now we can enter the mysql prompt as folows,
# mysql
Some time you may get an error as follws
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
To resolve this issue we need to find the exact sock which is connected to mysql.
# netstat -ax |grep mysql
My server given the following result
unix  2      [ ACC ]     STREAM     LISTENING     3821   /tmp/mysql.sock
Here the sock file is " /tmp/mysql.sock " . But our mysqlserver is trying to connect through " /var/lib/mysql/mysql.sock " . To resolve this issue do the following operations.
# pkill -9 mysql

# rm -rf /var/lib/mysql/mysql.sock

# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
Now start mysql again and enter into mysql prompt as follows
# bin/mysqld_safe --user=mysql &

# mysql
So our Mysql installations are finished

5. Install Php

In this section we can install php as FastCGI.
First to download and untar the php source.
# wget http://us2.php.net/get/php-5.2.0.tar.gz/from/in.php.net/mirror

# tar -xvzf  php-5.2.0.tar.gz
Let us install php as follows
# ./configure --prefix=/usr/local/php5/ --with-config-file-path=/usr/local/php5/etc   \
	 --enable-force-cgi-redirect --enable-fastcgi  \
	--with-gd --with-jpeg-dir=/usr/local --with-zlib --with-openssl 

# make 

# make install 

# cp php.ini-recommended /usr/local/php5/etc/php.ini
Now configure our lighty configuration as follows
# pico /etc/lighttpd/lighttpd.conf
Add the following lines to this conf file
fastcgi.server = ( ".php" =>

                   ( "localhost" =>

                     ( "socket" => "/tmp/php5-fcgi.socket",

                       "bin-path" => "/usr/local/php5/bin/php"

                     )

                   )

                 )

server.modules              = (

 				 "mod_fastcgi"

				)
Now create a phpinfo() file in the documet-root
# echo "" >>/var/www/html/phpinfo.php
Let us give ownership to this file.
# chown lighttpd.lighttpd /var/www/html/phpinfo.php
Let us restart our Lighty
# /etc/init.d/lighttpd restart
You can verify the php configurations from the browser as follws
http://192.168.1.201/phpinfo.php
Note: Sometimes the lighty will not start due to "/tmp/php5-fcgi.socket". Because the " /tmp" folder will not have proper permissions. So you can give the permissions as follows
# chmod 777 /tmp 
So we finished Our php installation.

6. Conclusion

Now we configured a LLMP(Linux+Lighttpd+Mysql+Php) environment.You can configure all of this packages with more options.

A. Acknowledgment

Special Thanks to Sangeetha ( Director ,Bobcares)
Special thanks to Tobby

B. Downloads


Articles by Sherinmon A About the author: Sherinmon works as System Administrator. He audits and maintains VPS servers for Datacenters.

In addition to System Administration, his passion is KungFu. He is a certified KungFu master.

 
spacer.gif
spacer.gif spacer.gif spacer.gif spacer.gif
Online
There are 16 guests and 0 members online.
 
FAQ | AUP | Partners | Contact Us | RSS RSS | Sitemap
© Poornam Info Vision LLC. All rights reserved.
Call us Toll Free: 1800-383-5193