- 论坛徽章:
- 0
|
LIGHTTPD + MYSQL + PHP(FAST-CGI)
欢迎大家转贴这个文章,但要保留下面的版权信息:
作者:llzqq
联系:llzqq@126.com
来自:www.chinaunix.net
Lighttp是一个新兴的安全,高效,兼容性都非常好的WEB服务器软件。相对APACHE来说lighttpd的显著特点是:非常低的内存占用,非常快的相应速度。今天我在LINUX上配置了一下感觉的确不错,在这里和大家分享一下。安装lighttpd前需要预装下列软件包:
pcre
zlib
pcre-devel
zlib-devel
1.安装配置lighttpd
1.1 首先创建运行lighttpd的用户和组
# groupadd lighttpd
# useradd -g lighttpd -s /sbin/nologin -d /dev/null lighttpd
1.2 开始安装lighttpd
# wget http://www.lighttpd.net/download/lighttpd-1.4.8.tar.gz
# tar -zxvf lighttpd-1.4.8.tar.gz
# cd lighttpd-1.4.8
# ./configure --prefix=/usr/local/lighttpd
# make
# make install
# mkdir /usr/local/lighttpd/conf
# mkdir /usr/local/lighttpd/log
# mv ./doc/lighttpd.conf /usr/local/lighttpd/conf/
# cp ./doc/rc.lighttpd.redhat /etc/init.d/lighttpd
1.3 配置lighttpd
# vi /usr/local/lighttpd/conf/lighttpd.conf
================+===============+================
server.modules = (
"mod_rewrite",
"mod_redirect",
"mod_access",
"mod_fastcgi",
"mod_compress",
"mod_accesslog" )
#$HTTP["url"] =~ "\.pdf$" {
#server.range-requests = "disable"
#}
server.document-root = "/usr/local/lighttpd/html"
server.errorlog = "/usr/local/lighttpd/log/lighttpd.error.log"
accesslog.filename = "/usr/local/lighttpd/log/access.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "lighttpd"
server.groupname = "lighttpd"
compress.cache-dir = "/tmp"
compress.filetype = ("text/plain", "text/html")
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/usr/local/php-fcgi/bin/php"
)
)
)
================+===============+================
# cp ./doc/spawn-php.sh /usr/local/lighttpd/bin/
# chown -R lighttpd:lighttpd /usr/local/lighttpd
2.安装配置MYSQL服务器
# yum install mysql-server
# yum install mysql
# service mysqld start
3. 安装配置PHP(FAST-CGI)
3.1 下载安装PHP
# cd ..
# wget http://mirrors.easynews.com/php/php-4.3.10.tar.gz
# tar -zxvf php-4.3.10.tar.gz
# cd php-4.3.10
# ./configure \
--prefix=/usr/local/php-fcgi \
--enable-fastcgi --with-mysql \
--enable-zend-multibyte \
--with-config-file-path=/etc \
--enable-discard-path \
--enable-force-cgi-redirect
# make
# make install
# cp php.ini-dist /etc/php.ini
4. 安装配置EAccelerator(PHP加速器)
4.1 下载安装EAccelerator
# cd ..
# wget http://kent.dl.sourceforge.net/sourceforge/eaccelerator/ \
eaccelerator-0.9.4-rc1.tar.bz2
# bunzip2 -d eaccelerator-0.9.4-rc1.tar.bz2
# tar -xvf eaccelerator-0.9.4-rc1.tar
# cd eaccelerator-0.9.4-rc1
# export PHP_PREFIX="/usr/local/php-fcgi"
# $PHP_PREFIX/bin/phpize
# ./configure \
--enable-eaccelerator=shared \
--with-php-config=$PHP_PREFIX/bin/php-config
# make
# make install
# cat eaccelerator.ini >> /etc/php.ini
4.2 配置PHP变量
# vi /etc/php.ini
================+===============+================
cgi.fix_pathinfo = 1
extension_dir = "/usr/local/php-fcgi/lib/php/extensions/\
no-debug-non-zts-20020429/"
zlib.output_compression = On
cgi.fix_pathinfo=1
eaccelerator.cache_dir="/tmp"
////下面的是关于eaccelerator的配置////
zend_extension="/usr/local/php-fcgi/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so"
eaccelerator.shm_size = "0"
eaccelerator.cache_dir = "/tmp"
eaccelerator.enable = "1"
eaccelerator.optimizer = "1"
eaccelerator.debug = 0
eaccelerator.log_file = "/var/log/eaccelerator_log"
eaccelerator.name_space = ""
eaccelerator.check_mtime = "1"
eaccelerator.filter = ""
eaccelerator.shm_max = "0"
eaccelerator.shm_ttl = "0"
eaccelerator.shm_prune_period = "0"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"
eaccelerator.keys = "shm_and_disk"
eaccelerator.sessions = "shm_and_disk"
eaccelerator.content = "shm_and_disk"
eaccelerator.admin.name="yourusername"
eaccelerator.admin.password="yourpassword"
================+===============+================
4.3 初始化PHP with FastCGI
# vi /usr/local/lighttpd/bin/spawn-php.sh
================+===============+================
SPAWNFCGI="/usr/local/lighttpd/bin/spawn-fcgi"
FCGIPROGRAM="/usr/local/php-fcgi/bin/php"
USERID=lighttpd
GROUPID=lighttpd
================+===============+================
# /usr/local/lighttpd/bin/spawn-php.sh
5. 测试
把/etc/init.d/lighttpd文件中不符的路径更改一下
# chmod 755 /etc/init.d/lighttpd
# chown root:root /etc/init.d/lighttpd
# chkconfig --add lighttpd
# chkconfig lighttpd on
# service lighttpd start
# ps afx | grep php
12222 pts/2 S 0:00 \_ grep php
12193 ? S 0:00 /usr/local/php-fcgi/bin/php
12194 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
12195 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
12196 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
12197 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
12198 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
12199 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
12200 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
12201 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
12202 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
12203 ? S 0:00 \_ /usr/local/php-fcgi/bin/php
最后在server.document-root目录中放一个test.php,用浏览器看看结果。
http://llzqq.3322.org/test.php
[ 本帖最后由 llzqq 于 2005-12-3 07:42 编辑 ] |
|