How to install Lighttpd with PHP5 and MySQL on CentOS 5.2

In this tutorial I will show you how to with and MqSQL on 5.2.

What is Lighttpd?

Lighttpd is a webserver designed to be secure, fast, standards-compliant, and flexible while being optimized for speed-critical environments. This post shows how to install it with PHP5 and support on Centos 5.2.

Step 1: Install MySQL

[[email protected] ~]# yum -y install mysql mysql-server

Step 2: Create the system startup links for MySQL

[[email protected] ~]# chkconfig --levels 235 mysqld on
[[email protected] ~]# /etc/init.d/mysqld start

Step 3: Create Password for the MySQL root User

[[email protected] ~]# mysqladmin -u root password server123

Step 4: Check if MySQL Networking is enabled

[[email protected] ~]# netstat -tap | grep mysql

Step 5: Set a MySQL password for your hostname

[[email protected] ~]# mysqladmin -h localhost -u root password server123

Step 6: Installing Lighttpd

[[email protected] ~]# rpm -Uhv  http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[[email protected] ~]# yum -y install lighttpd

Step 7: Create the system startup links for Lighttpd

[[email protected] ~]# chkconfig --levels 235 lighttpd on
[[email protected] ~]# /etc/init.d/lighttpd start

Step 8: Check service lighttpd

[[email protected] ~]# netstat -tap | grep lighttpd

Step 9: Install PHP 5

[[email protected] ~]# yum install lighttpd-fastcgi php-cli

Step 10: Add the line cgi.fix_pathinfo = 1 right at the end of the file /etc/php.ini

[[email protected] ~]# nano /etc/php.ini
cgi.fix_pathinfo = 1

Step 11: Uncomment “mod_fastcgi” in the file /etc/lighttpd/lighttpd.conf

[[email protected] ~]# nano /etc/lighttpd/lighttpd.conf
server.modules = (
#              "mod_rewrite",
#              "mod_redirect",
#              "mod_alias",
               "mod_access",
#              "mod_cml",
#              "mod_trigger_b4_dl",
#              "mod_auth",
#              "mod_status",
#              "mod_setenv",
               "mod_fastcgi",
#              "mod_proxy",
#              "mod_simple_vhost",
#              "mod_evhost",
#              "mod_userdir",
#              "mod_cgi",
#              "mod_compress",
#              "mod_ssi",
#              "mod_usertrack",
#              "mod_expire",
#              "mod_secdownload",
#              "mod_rrdtool",
               "mod_accesslog" )

And then uncomment these few lines:

#### fastcgi module
## read fastcgi.txt for more info
fastcgi.server = ( ".php" =>
               ( "localhost" =>
                 (
                             "socket" => "/tmp/php-fastcgi.socket",
                             "bin-path" => "/usr/bin/php-cgi"
                 )
               )
)

Finally Step 12: Restart service lighttpd

[[email protected] ~]# /etc/init.d/lighttpd restart

Step 13: Testing PHP 5

[[email protected] ~]# nano /srv/www/lighttpd/info.php
<?php
phpinfo();
?>

Step 14: Now check in browser http://localhost/info.php

Step 15: Getting MySQL in PHP5

[[email protected] ~]# yum -y install php-mysql php-gd php-imap php-ldap  php-odbc php-pear php-xml php-xmlrpc

Step 16. Restart service lighttpd

[[email protected] ~]# /etc/init.d/lighttpd restart
 and check using http://localhost/info.php.
Comments
  1. Savke

    Great tutorials. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *