lighttpd + mysql + php(fast-cgi)安装与配置

准备:
lighttpd-1.4.15.tar.gz
php-4.4.2.tar.gz
mysql-5.0.20a.tar.gz

开始:
1 编译安装lighttpd

 # tar zxvf lighttpd-1.4.15.tar.gz
 # cd lighttpd-1.4.15
 #  ls
 # ./configure --prefix=/usr/local/lighttpd    //此部无法编译时提示安装prce-devel
 #  make
 #  make install

 创建网站根目录
 # mkdir /usr/local/lighttpd/htdocs
 创建配置文件放置目录
 #mkdir /usr/local/lighttpd/etc
创建日志目录
#mkdir /usr/local/lighttpd/logs
将配置文件拷贝到/usr/local/lighttpd/etc
#cp doc/lighttpd.conf /usr/local/lighttpd/etc
 
 启动lighttpd
 #/usr/local/lighttpd/sbin/lighttpd -f /usr/local/lighttpd/etc/lighttpd.conf

 

我在安装的时候在error日志出现 opening errorlog '/var/log/lighttpd/access.log

在/var/log下建立lighttpd目录就可以了
 


2 安装 MYSQL
#  tar zxvf mysql-5.0.20a.tar.gz
#  cd mysql-5.0.20a
#  ./configure --prefix=/usr/local/mysql
#  make;make install

# groupadd mysql
# useradd -g mysql mysql

# cp support-files/my-medium.cnf /etc/my.cnf
# cd /usr/local/mysql/

初始化
#  bin/mysql_install_db --user=mysql
运行
bin/mysqld_safe --user=mysql &
设置自动启动(略)

3 安装 php (fast-cgi)
# tar zxvf php-4.4.2.tar.gz
# cd php-4.4.2
编译,加 --enable-fastcgi 和 --enable-force-cgi-redirect 选项
# ./configure --prefix=/usr/local/php-fastcgi  --enable-fastcgi --enable-force-cgi-redirect --with-zlib --
with-gd --with-ttf --with-png --with-expat-dir=/usr --with-gmp --with-xml --with-mysql=/usr/local/mysql --with-
charset=utf-8 --disable-debug --disable-posix --disable-rpath --enable-safe-mode --enable-magic-quotes --disabl
e-dmalloc --enable-bcmath --enable-dio --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-wddx -
-enable-versioning --enable-pic --enable-inline-optimization --enable-memory-limit --enable-mbstring --enable-m
bregex --enable-mbstr-enc-trans --with-config-file-path=/usr/local/lib --enable-ftp --disable-debug --enable-tr
ack-vars=yes --with-jpeg-dir --with-freetype-dir --enable-gd-native-ttf --enable-dl
# make;make install

4 配置lighttpd

#vim /usr/local/lighttpd/etc/lighttpd.conf

修改一下内容

---------------- 加载cgi,fastcgi模块-------------
14 server.modules              = (
 15                                 "mod_rewrite",
 16 #                               "mod_redirect",
 17 #                               "mod_alias",
 18                                 "mod_access",
 19 #                               "mod_cml",
 20 #                               "mod_trigger_b4_dl",
 21 #                               "mod_auth",
 22 #                               "mod_status",
 23 #                               "mod_setenv",
 24                                 "mod_fastcgi",
 25 #                               "mod_proxy",
 26 #                               "mod_simple_vhost",
 27 #                               "mod_evhost",
 28 #                               "mod_userdir",
 29                                 "mod_cgi",
 30 #                               "mod_compress",
 31 #                               "mod_ssi",
 32 #                               "mod_usertrack",

----------------------------网站根目录---------------------------------
 38 ## a static document-root, for virtual-hosting take look at the
 39 ## server.virtual-* options
 40 server.document-root        = "/usr/local/lighttpd/htdocs"

----------------------------日志目录------------------------------
42 ## where to send error-messages to
 43 server.errorlog             = "/usr/local/lighttpd/logs/lighttpd.error.log"
.....
.....
115 #### accesslog module
116 accesslog.filename          = "/usr/local/lighttpd/logs/access.log"

-----------------------------默认首页格式-------------------------
 45 # files to check for if .../ is requested
 46 index-file.names            = ( "index.php", "index.html",
 47                                 "index.htm", "default.htm" )

-----------------------------FastCgi模块---------------------------
206 #### fastcgi module
207 ## read fastcgi.txt for more info
208 ## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
209 fastcgi.server= (".php" =>
210 (( "socket" => "/tmp/php.socket",
211  "bin-path" => "/usr/local/php-fastcgi/bin/php",
212  "min-procs" => 1,
213  "max-procs" => 32,
214  "max-load-per-proc" => 4,
215  "idle-timeout" => 20
216  ))
217  )


------------------------------CGI模块----------------------------------
243 #### CGI module
244 cgi.assign                 = (
245                                 ".sh" => "/bin/bash",     #shell script
246                                 ".pl"  => "/usr/bin/perl",  #Perl
247                                ".cgi" => "" )   #  c/c++
248 #

5 修改php.ini

设置 cgi.fix_pathinfo = 1


6 配置完毕,重起lighttpd
查其PID
# ps  auxww |grep lighttpd
kill掉
# kill -9 PID
启动
# /usr/local/lighttpd/bin/lighttpd -f /usr/local/lighttpd/etc/lighttpd.conf



7.简单管理脚本
为了方便管理lighttpd,写几个简单的脚本

checkLighttpd.sh(检查lighttpd进程):
-------------------------------------
#!/bin/bash
ps auxww |grep lighttpd|grep -v grep
-------------------------------------

killLighttpd.sh(杀死lighttpd进程) :
-------------------------------------
#!/bin/bash
LIGHTTPD_PID=`ps auxww |grep lighttpd |grep -v grep | awk '{print $2}'`
kill -9 $LIGHTTPD_PID
-------------------------------------

startLighttpd.sh (启动lighttpd):
-------------------------------------
 #!/bin/bash
 /usr/local/lighttpd/***in/lighttpd -f /usr/local/lighttpd/etc/lighttpd.conf
-------------------------------------

# chmod +x  startLighttpd.sh killLighttpd.sh checkLighttpd.sh


8 测试:
用c,shell,perl,php分别写几个小程序作测试(略)
注: 经测试, php  要用<?php  ?> ,使用<? ?>竟然解析不出来,php5与php4的一点差别,需要修改php.ini

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值