lighttpd

来源:互联网 发布:sql 第三大值 编辑:程序博客网 时间:2024/05/16 04:43

 搭建lighttpd+php+mysql环境
宿主机的配置:
Linux pojaa101
内核:2.6.18-92.1.18.el5.028stab060.2
主机架构:i686 i686 i386 GNU/Linux
php版本是:php-5.2.9
mysql版本是:mysql-5.0.67
lighttpd版本是:lighttpd-1.4.16

下载安装包:
lighttpd-1.4.16.tar.gz
mysql-5.0.67.tar.gz
php-5.2.9.tar.gz


1.安装mysql
wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.67.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
tar xzvf mysql-5.0.67.tar.gz
cd mysql-5.0.67
./configure --prefix=/var/mysql
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
cd /var/mysql
adduser -s /bin/bash -m -k /dev/null mysql
bin/mysql_install_db –user=mysql
chown -R root .
Chown -R mysql var
chgrp -R mysql .
bin/mysqld_safe –user=mysql &
chkconfig –add mysqld
chkconfig –level 345 mysqld on
mysqladmin -uroot password “123”
service mysqld restart
完成mysql的安装,可能会出现一下的问题:
(1)在configure安装配置mysql的时候出现:
checking for termcap functions library... configure: error: No curses/termcap library found
解决方法: 指定curses的lib库文件。
 ./configure --prefix=/var/mysql --with-named-curses-libs=/usr/lib/libncursesw.so.5
(2)在make时遇到
 -fno-rtti -c -o my_new.o my_new.cc
../depcomp: line 512: exec: g++: not found
make[2]: *** [my_new.o] Error 127
make[2]: Leaving directory `/root/mysql-5.0.67/mysys'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/mysql-5.0.67'
make: *** [all] Error 2

解决办法
yum install gcc-g++
安装 gcc-c++ 和他的依赖libstdc++-devel
(3)在make时可能出现:
 -fno-rtti -c -o my_new.o my_new.cc
../include/my_global.h:988: error: redeclaration of C++ built-in type ‘bool’
make[2]: *** [my_new.o] Error 1
make[2]: Leaving directory `/root/mysql-5.0.67/mysys'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/mysql-5.0.67'
make: *** [all] Error 2

解决方法是重新configure 然后再make 和make install

2.安装lighttpd
首先它依赖的包分别是:glib2-devel openssl-devel pcre-devel bzip2-devel
tar zxvf lighttpd-1.4.16.tar.gz
cd lighttpd-1.4.16
mkdir -p /var/lighttpd/www/{pages,logs}
./configure –prefix=/var/lighttpd
make
make install
cp /doc/lighttpd.conf /var/lighttpd/
cd /var/lighttpd/
vi lighttpd.conf
修改server.document-root、和server.errorlog、以及accesslog.filename:
server.document-root        = "/var/lighttpd/www/pages/"
server.errorlog             = "/var/lighttpd/www/logs/lighttpd.error.log"
accesslog.filename          = "/var/lighttpd/www/logs/access.log"
安装完毕其中可能遇到的问题:
(1)缺少依赖
[root@pojaa101 lighttpd]# sbin/lighttpd -f lighttpd.conf
can't handle '$HTTP[url] =~ ...' as you compiled without pcre support.
(perhaps just a missing pcre-devel package ?)
2009-04-18 05:37:41: (configfile.c.853) source: lighttpd.conf line: 126 pos: 3 parser failed somehow near here: {
解决方法:# yum install glib2-devel openssl-devel pcre-devel bzip2-devel flex gzip-devel 然后重新编译lighttpd加上参数--with-pcre
(2)在配置文件中需要用到lex命令,如果没有安装flex则会出现:
checking lex output file root... ./configure: line 2482: lex: command not found
configure: error: cannot find output from lex; giving up 的错误
解决方法:yum install flex
3.安装php且和lighttpd配合
mkdir -p /var/php529/fcgi
tar zxvf php-5.2.9.tar.gz
cd php-5.2.9
./configure –prefix=/var/php529
make
cp sapi/cgi/php-cgi /var/ php529/fcgi/
vi /var/lighttpd/lighttpd.conf
修改一下内容:
(1)
server.moudules中把mod_fastcgi的注释去掉
(2)
fastcgi.server             = ( ".php" =>
                               ( "localhost" =>
                                 (
                                   "socket" => "/tmp/php-fastcgi.socket",
#                                   "bin-path" => "/usr/local/bin/php"
                                   "bin-path" => "/var/lighttpd/fcgi/php-cgi"
                                 )
                               )
                            )
/var/lighttpd/sbin/lighttpd -f /var/lighttpd/lighttpd.conf 运行lighttpd
可能出现的错误:
(1)在configure的时候
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
解决方法:yum install libxml2-devel
4.修改符合自己的lighttpd的启动脚本用来方便管理
如下:
#!/bin/sh
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/lighttpd ]; then
        . /etc/sysconfig/lighttpd
fi

if [ -z "$LIGHTTPD_CONF_PATH" ]; then
        LIGHTTPD_CONF_PATH="/var/lighttpd/lighttpd.conf"
fi

prog="lighttpd"
lighttpd="/var/lighttpd/sbin/lighttpd"
RETVAL=0
start() {
        echo -n $"Starting $prog: "
        daemon $lighttpd -f $LIGHTTPD_CONF_PATH
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        killproc $lighttpd
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

reload() {
        echo -n $"Reloading $prog: "
        killproc $lighttpd -HUP
        RETVAL=$?
        echo
        return $RETVAL
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        condrestart)
                if [ -f /var/lock/subsys/$prog ]; then
                        stop
                        start
                fi
                ;;
        reload)
                reload
                ;;
        status)
                status $lighttpd
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
                RETVAL=1
esac

exit $RETVAL

5.
配置cgi对于带扩展名且需要特定解析程序执行的CGI,可以指定解析程序的路径
修改 server.modules 中的mod_access和mod_cgi以及mod_accesslog
cgi.assign                 = ( ".pl"  => "/usr/bin/perl",
                               ".cgi" => "/usr/bin/perl" )
cgi.assign                 = ( ".cgi"  => "")
cgi.assign                 = ( "/cgi-bin/mycgi"  => "/usr/local/cgi/mycgi")

原创粉丝点击