« »
2008-02-03Lighttpd

277

lighttpd 安裝教程

  • 安裝 PHP as FastCGI
  • 安裝 lighttpd Web Server
  • PHP extensions 安裝備忘
    • eAccelerator: PHP 加速器
    • htscanner: .htaccess 的 PHP 應用

操作環境

  • Fedora Core 3 Linux
  • yum install httpd mysql mysql-server mysql-devel
    模擬已裝有 apache http server & mysql 的環境

安裝 PHP as FastCGI

需求套件: flex, mysql-devel

wget http://tw2.php.net/get/php-4.4.6.tar.bz2/from/tw.php.net/mirror

tar jxf php-4.4.6.tar.gz2

cd php-4.4.6

./configure \
    –prefix=/usr/local/php-fcgi \
    –enable-fastcgi \
    –enable-force-cgi-redirect \
    –enable-mbstring \
    –with-mysql=/usr

make && make install

cp php.ini-recommended /usr/local/php-fcgi/lib/php.ini

echo “cgi.fix_pathinfo=1″ >> /usr/local/php-fcgi/lib/php.ini

安裝 lighttpd

需求套件: gcc, pcre-devel

wget http://www.lighttpd.net/assets/2007/1/29/lighttpd-1.4.13.tar.gz

tar zxf lighttpd-1.4.13.tar.gz

cd lighttpd-1.4.13

./configure –prefix=/usr/local/lighttpd

make && make install

cd doc

mkdir /etc/lighttpd

cp lighttpd.conf /etc/lighttpd

cp sysconfig.lighttpd /etc/sysconfig/lighttpd

cp rc.lighttpd.redhat /etc/init.d/lighttpd

vi /etc/inid.d/lighttpd

lighttpd=”/usr/local/lighttpd/sbin/lighttpd”

vi /etc/lighttpd/lighttpd.conf

#取消註解需要的模組
server.modules = (
    “mod_alias”,
    “mod_access”,
    “mod_fastcgi”,
    “mod_cgi”,
    “mod_accesslog” )

server.document-root = “/var/www/html/”
server.errorlog = “/var/log/httpd/error_log”
accesslog.filename = “/var/log/httpd/access_log”
url.access-deny = ( “~”, “.inc”, “.htaccess” )
server.pid-file = “/var/run/lighttpd/lighttpd.pid”
server.username = “apache”
server.groupname = “apache”

#取消註解
fastcgi.server = ( “.php” =>
    ( “localhost” =>
        (
            “socket” => “/tmp/php-fastcgi.socket”,
            “bin-path” => “/usr/local/php-fcgi/bin/php”
        )
    )
)

#取消註解
cgi.assign = ( “.pl” => “/usr/bin/perl”,
    ( “.cgi” => “/usr/bin/perl” )

#加入底下這行:
alias.url = ( “/cgi-bin” => “/var/www/cgi-bin” )
#若有多個 alias, 全寫進小括弧內, 並以逗號區隔

更多的 lighttpd.conf 設定參考:

mkdir /var/run/lighttpd

chown apache:apache /var/run/lighttpd

chown -R apache:apache /var/log/httpd

cd /etc/logrotate.d

vi httpd

複製 ‘/bin/kill …’ 這行, 並將原本的設置打上註解符號, 另一行改成 lighttpd.pid

#/bin/kill -HUP `cat /var/run/httpd/httpd.pid 2>/dev/null` …

/bin/kill -HUP `cat /var/run/lighttpd/lighttpd.pid 2>/dev/null` …

chkconfig httpd off

/etc/init.d/httpd stop

/etc/init.d/lighttpd start

chkconfig lighttpd on

PHP Extensions 安裝備忘

eAccelerator

作用: 加速 PHP 網頁 (Ref: jerome’s blog)

下載 eAccelerator (以 v0.9.5 為例)

tar jxf eaccelerator-0.9.5.tar.bz2

cd eaccelerator-0.9.5

/usr/local/php-fcgi/bin/phpize

./configure \
    –enable-eacclerator
    –with-php-config=/usr/local/php-fcgi/bin/php-config

make && make install

cat eaccelerator.ini >> /usr/local/php-fcgi/lib/php.ini

vi /usr/local/php-fcgi/lib/php.ini

zend_extension=”/usr/local/php-fcgi/lib/php/extensions/no-debug-non-zts/20020429/eaccelerator.so”
eaccelerator.log_file = “/var/log/httpd/eaccelerator_log”

mkdir /tmp/eaccelerator

chown apache:apache /tmp/eaccelerator

htscanner

作用: 利用 .htaccess 設置 php_flag、php_value 變更 php 參數 (Ref: Tsung’s Blog & PHP 手冊)

wget http://pecl.php.net/get/htscanner-0.8.0.tgz

tar zxf htscanner-0.8.0.tgz

cd htscanner-0.8.0

/usr/local/php-fcgi/bin/phpize

./configure \
    –enable-htscanner \
    –with-php-config=/usr/local/php-fcgi/bin/php-config

make && make install

cat ./docs/htscanner.ini >> /usr/local/php-fcgi/lib/php.ini

vi /usr/local/php-fcgi/lib/php.ini

extension_dir=”/usr/local/php-fcgi/lib/php/extensions/no-debug-non-zts-20020429/”
extension=”htscanner.so”
htscanner.config_file=”.htaccess”
htscanner.default_docroot=”/var/www/html”
htscanner.default_ttl=300
htscanner.stop_on_error=0

ps.原本無 “htscanner.” 要加上去才有效果

相關連結

您还可能感兴趣的内容

日志信息 »

该日志于2008-02-03 16:20由 x72 发表在Lighttpd分类下, 通告目前不可用,你可以至底部留下评论。

没有评论

发表评论 »


返回顶部