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=/usrmake && 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 安裝備忘
作用: 加速 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-configmake && 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
作用: 利用 .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-configmake && 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=0ps.原本無 “htscanner.” 要加上去才有效果
相關連結
- lighttpd 官方網頁
- Wikipedia – lighttpd
- ONLamp.com – The lighttpd Web Server
- lighttpd,thttpd,shttpd – 轻量级webserver介绍
没有评论▼