9/07/2010

Install Lighttpd with PHP5 and MySQL on CentOS 5.4

[1] Install MySQL 5.0

- Use command line:
yum install mysql mysql-server

- Start MySQL with OS
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

- Take password for root on MySQL
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword

[2] Install Lighttpd

1. Download packet rpmforge-release if system your is x86_64 and install
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

- If system your is i386 and install
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

2. Install Lighttpd
yum install lighttpd

3. Start Lighttpd with OS
chkconfig --levels 235 lighttpd on
/etc/init.d/lighttpd start

[3] Install PHP5

1. Install Lighttpd-fastcgi and php-cli
yum install lighttpd-fastcgi php-cli

2. Configuring Lighttpd And PHP5
- Open /etc/php.ini add "cgi.fix_pathinfo = 1"
[...]
cgi.fix_pathinfo = 1

3. Open /etc/lighttpd/lighttpd.conf and uncomment "mod_fastcgi"
[...]
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" )
[...]

4. In file lighttpd.conf, after uncomment "fastcgi.server"
[...]
#### fastcgi module
## read fastcgi.txt for more info
## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi"
)
)
)
[...]

5. Restart service Lighttpd
/etc/init.d/lighttpd restart

6. Take file /srv/www/lighttpd/info.php
phpinfo();
?>

7. Open brows add address http://ip_your/info.php

[4] Configuring PHP5 support MySQL

1. Install php-mysql
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

2. Restart Lighttpd
/etc/init.d/lighttpd restart

No comments:

Post a Comment