在CentOS 5.2上安装带有PHP5和MySQL的Lighttpd
什么是Lighttpd?
Lighttpd是一款网络服务器,旨在安全,快速,符合标准和灵活性,同时针对速度至关重要的环境进行优化。 这篇文章显示如何在Centos 5.2上使用PHP5和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@server ~]# mysqladmin -u root password server123
4.检查MySQL网络是否启用
[root@server ~]# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 19852/mysqld
为您的主机名设置一个MySQL密码
[root@server ~]# mysqladmin -h localhost -u root password server123
6.安装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
[root@server ~]# yum -y install lighttpd
7.创建Lighttpd的系统启动链接
[root@server ~]# chkconfig --levels 235 lighttpd on
[root@server ~]# /etc/init.d/lighttpd start
8.检查服务lighttpd
[root@server ~]# netstat -tap | grep lighttpd
tcp 0 0 *:http *:* LISTEN 28352/lighttpd
9.安装PHP5
[root@server ~]# yum install lighttpd-fastcgi php-cli
10.在文件/etc/php.ini的末尾添加行cgi.fix_pathinfo = 1
[root@server ~]# nano /etc/php.ini
cgi.fix_pathinfo = 1
11.在/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" ) ) )
12.重启服务lighttpd
[root@server ~]# /etc/init.d/lighttpd restart
13.测试PHP5
[root@server ~]# nano /srv/www/lighttpd/info.php
<?php phpinfo(); ?>
现在检查浏览器http://localhost/info.php
在PHP5中获取MySQL
[root@server ~]# yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
16.重启服务lighttpd
[root@server ~]# /etc/init.d/lighttpd restart
并检查使用http://localhost/info.php
。