首页 > CentOS, Lighttpd > 在CentOS5.2中安装Lighttpd+PHP5+MySQL

在CentOS5.2中安装Lighttpd+PHP5+MySQL

2010年7月6日 [post_view] 发表评论 阅读评论

源文地址:http://www.howtoforge.com/installing-lighttpd-with-php5-and-mysql-on-centos-5.2
Lighttpd是什么?

Lighttpd是一款安全,高效,基于标准且为高速环境设计的web服务器。这篇教程将教你如何在一台CentOS 5.2中安装Lighttpd+PHP5(FastCGI模式)+MySQL。

1.安装MySQL
[root@server ~]# yum -y install mysql mysql-server
2.为MySQL添加自启动
[root@server ~]# chkconfig --levels 235 mysqld on
[root@server ~]# /etc/init.d/mysqld start
3.为MySQL的root用户添加密码
[root@server ~]# mysqladmin -h localhost -u root password server123
4.检查MySQL是否正常运行
[root@server ~]# netstat -tap | grep mysql
 
tcp        0      0 *:mysql                     *:*                         LISTEN      19852/mysqld
5.安装Lighttpd

首先导入更新包

[root@server~]#rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

安装Lighttpd

[root@server ~]# yum -y install lighttpd
6.为Lighttpd创建自启动
[root@server ~]# chkconfig --levels 235 lighttpd on
[root@server ~]# /etc/init.d/lighttpd start
7.检查lighttpd服务
[root@server ~]# netstat -tap | grep lighttpd
 
tcp        0      0 *:http                      *:*                         LISTEN      28352/lighttpd
8.安装PHP5
[root@server ~]# yum install lighttpd-fastcgi php-cli
9.在/etc/php.ini文件中添加 cgi.fix_pathinfo = 1
[root@server ~]# nano /etc/php.ini
cgi.fix_pathinfo = 1
10.在 /etc/lighttpd/lighttpd.conf文件中注销掉 "mod_fastcgi"
[root@server ~]# 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" )

然后注销这些行:

#### fastcgi module
## read fastcgi.txt for more info
fastcgi.server = ( ".php" =>
               ( "localhost" =>
                 (
                             "socket" => "/tmp/php-fastcgi.socket",
                             "bin-path" => "/usr/bin/php-cgi"
                 )
               )
)
11.重启Lighttpd服务
[root@server ~]# /etc/init.d/lighttpd restart
12.测试PHP5
[root@server ~]# nano /srv/www/lighttpd/info.php
<?php
phpinfo();
?>

现在你就可以在 http://localhost/info.php里看到PHP的相关信息

13.使得MySQL支持PHP5
[root@server ~]# yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
14.重启Lighttpd服务
[root@server ~]# /etc/init.d/lighttpd restart

在http://localhost/info.php中检测看是否MySQL模块被加载

分类: CentOS, Lighttpd 标签: , , ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.