lighttpd 配置 Php 环境
首先说明一下,版本很重要,因为不同的php,lighttpd,会有不同的结果;我这里先说明一下,我采用的版本。php 5.1.6
lighttpd 1.4.2
eaccelerator-0.9.5.3(目前这个还没有安装成功)
1、安装php
#tar xjvf php 5.1.6.bz2
#cd php 5.1.6
#./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
在这个过程中碰到过没有一个包安装的情况,如果你碰到类似的报错,通过yum install “包名” 就可以,
但是我碰到的是 libxml2 这个包没有安装;但是通过安装过后,依然报这个包没有安装,后来查找了一下,
原来是还有一个依赖包,libxml2-devel ,把这个也通过 yum 安装了就好了。
# make
# make install
# cp php.ini-dist /etc/php.ini
2. 安装配置EAccelerator(PHP加速器)
2.1 下载安装EAccelerator
# cd ..
# wget http://kent.dl.sourceforge.net/sourceforge/eaccelerator/ \
eaccelerator-0.9.5.3
# tar xjvf eaccelerator-0.9.5.3.bz2
# cd eaccelerator-0.9.5.3
# 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
3.1 配置lighttpd
# vi /etc/lighttpd/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" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 2,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"bin-copy-environment" => (
"PATH", "SHELL", "USER"
),
"broken-scriptfilename" => "enable"
)))
$HTTP["host"]=="【IP或者域名】"{
server.document-root = "/home/test/php/"
#url.rewrite = (
#"^/?$" => "/index.php",
#"^/(\?.*)$" => "/index.php$1",
#"^/(wp-.+)$" => "$0",
#"^/([^.]+)/?$" => "/index.php?$1",
#)
}
通过这些配置,基本就可以了,但是因为EAccelerator还没有安装成功(不影响lighttpd 运行php),所以效率上不太好,这个以后研究。
剩下的就是看看怎么才能执行php,做一个测试的php,一般就是
在自己 server.document-root 下面写一个测试php,例如常见的
<?php
phpinfo();
?>
测试一下,就可以看到了。
页:
[1]