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
1 | tar zxvf lighttpd-1.4.15.tar.gz |
创建网站根目录
1 | mkdir /usr/local/lighttpd/htdocs |
创建配置文件放置目录
1 | mkdir /usr/local/lighttpd/etc |
创建日志目录
1 | mkdir /usr/local/lighttpd/logs |
将配置文件拷贝到/usr/local/lighttpd/etc
1 | cp doc/lighttpd.conf /usr/local/lighttpd/etc |
启动lighttpd
1 | /usr/local/lighttpd/bin/lighttpd -f /usr/local/lighttpd/etc/lighttpd.conf |
2 安装 MYSQL
1 | tar zxvf mysql-5.0.20a.tar.gz |
初始化
1 | bin/mysql_install_db —user=mysql |
运行
1 | bin/mysqld_safe —user=mysql & |
设置自动启动(略)
3 安装 php (fast-cgi)
1 | tar zxvf php-4.4.2.tar.gz |
编译,加--enable-fastcgi
和--enable-force-cgi-redirect
选项
1 | ./configure --prefix=/usr/local/php-fastcgi --enable-fastcgi --enable-force-cgi-redirect --with-zlib \ |
4 配置lighttpd
1 | #vim /usr/local/lighttpd/etc/lighttpd.conf |
修改一下内容
加载cgi,fastcgi模块1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19server.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”,
网站根目录1
2
3## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root = “/usr/local/lighttpd/htdocs”
日志目录1
2
3
4
5
6## where to send error-messages to
server.errorlog = “/usr/local/lighttpd/logs/lighttpd.error.log”
…..
…..
#### accesslog module
accesslog.filename = “/usr/local/lighttpd/logs/access.log”
默认首页格式1
2
3# files to check for if …/ is requested
index-file.names = ( “index.php”, “index.html”,
“index.htm”, “default.htm” )
FastCgi模块1
2
3
4
5
6
7
8
9
10
11
12#### 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” =>
(( “socket” => “/tmp/php.socket”,
“bin-path” => “/usr/local/php-fastcgi/bin/php”,
“min-procs” => 1,
“max-procs” => 32,
“max-load-per-proc” => 4,
“idle-timeout” => 20
))
)
CGI模块1
2
3
4
5
6#### CGI module
cgi.assign = (
“.sh” => “/bin/bash”, #shell script
“.pl” => “/usr/bin/perl”, #Perl
“.cgi” => “”
)
5 修改php.ini
设置 cgi.fix_pathinfo = 1
6 配置完毕,重起lighttpd
查其PID1
ps auxww |grep lighttpd
kill掉1
kill -9 PID
启动1
/usr/local/lighttpd/bin/lighttpd -f /usr/local/lighttpd/etc/lighttpd.conf
7.简单管理脚本
为了方便管理lighttpd,写几个简单的脚本
checkLighttpd.sh(检查lighttpd进程):1
2#!/bin/bash
ps auxww |grep lighttpd|grep -v grep
killLighttpd.sh(杀死lighttpd进程) :1
2
3#!/bin/bash
LIGHTTPD_PID=ps auxww |grep lighttpd |grep -v grep | awk '{print $2}'
kill -9 $LIGHTTPD_PID
startLighttpd.sh (启动lighttpd):1
2
3#!/bin/bash
/usr/local/lighttpd/sbin/lighttpd -f /usr/local/lighttpd/etc/lighttpd.conf
chmod +x startLighttpd.sh killLighttpd.sh checkLighttpd.sh
8 测试:
用c,shell,perl,php分别写几个小程序作测试(略)