个人工具

Lighttpd

来自Ubuntu中文

跳转至: 导航, 搜索

介绍

lighttpd是众多OpenSource轻量级的web server中较为优秀的一个。支持FastCGI, CGI, Auth, 输出压缩(output compress), URL重写, Alias等重要功能。

Lighttpd

sudo apt-get install lighttpd   #安装lighttpd

安装后系统会自动启动lighttpd,打开http://localhost 便是,如果你之前有装Apache,那默认主页换成 http://localhost/index.lighttpd.html

web服务器的根目录是在 /var/www/ ,配置文件是在/etc/lighttpd/lighttpd.conf。

重启lighttpd的命令

sudo /etc/init.d/lighttpd restart 
Lighttpd默认页面

启用用户目录

启用用户目录后,每个用户的home目录便有自个的web目录。命令:

sudo lighttpd-enable-mod userdir

重新载入配置

sudo service lighttpd reload

现在用户可以放置文件到home目录下的public_html文件夹内。比如qii用户需要放置文件到/home/joe/public_html,打开 http://loaclhost/~qii

参考图

PHP

安装php5-cgi

sudo apt-get install php5-cgi

启用fastcgi:

sudo lighttpd-enable-mod fastcgi

重新载入配置:

sudo service lighttpd reload

创建、测试phpinfo:

sudo vi /var/www/info.php
<?php phpinfo(); ?>

打开 http://localhost/info.php

效果图

安装Zend Optimizer

要求PHP版本为5.2,不支持Ubuntu10.04的PHP5.3,请参照PHP5.2

下载 Zend Optimizer。 直接贴下载地址,参考版本号改(这是32位的),不然主页要注册才能下

 http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz 
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
cd ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp
sudo mkdir /usr/local/zend
sudo cp ZendOptimizer.so /usr/local/zend 

编辑php.ini

sudo gedit /etc/php5/cgi/php.ini

开头加入,注意标点符号要英文。

[Zend Optimizer]
zend_optimizer.optimization_level=1  
zend_extension="/usr/local/zend/ZendOptimizer.so"

重启lighttpd

sudo /etc/init.d/lighttpd restart 

还是上面那个phpinfo文件,要能看到如下信息

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

安裝XCache

sudo apt-get install php5-xcache
root@ubuntu:/home/qii# dpkg -l | grep xcach
ii  php5-xcache                          1.2.2-5                                         Fast, stable PHP opcode cacher

xcache配置文件路径是

/etc/php5/conf.d/xcache.ini

编辑php.ini

sudo gedit /etc/php5/cgi/php.ini

把xcache.ini的内容加入到php.ini。 重启lighttpd

sudo /etc/init.d/lighttpd restart  

检查安装是否成功

root@ubuntu:/home/qii# php -v
PHP 5.2.10-2ubuntu6 with Suhosin-Patch 0.9.7 (cli) (built: Oct 23 2009 16:30:10) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with XCache v1.2.2, Copyright (c) 2005-2007, by mOo

还有前面info.php页应该有XCache模块

info页面的XCache模块

这里有点奇怪的是,如果不把xcache.ini的内容加入php.ini,apache也能载入XCache,但info.php上没XCache模块。

安装eAccelerator

sudo apt-get install php5-dev

下载 eAccelerator

wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1 
phpize
sudo ./configure -enable-eaccelerator=shared
sudo make
qii@ubuntu:~/tmp/eaccelerator-0.9.6.1$ sudo make install
Installing shared extensions:     /usr/lib/php5/20060613+lfs/

修改php.ini文件,安装为Zend扩展,最好放在开头,放到[zend]之前,免的出莫名其妙的问题:

sudo vi /etc/php5/cgi/php.ini
[eaccelerator]
zend_extension="/usr/lib/php5/20060613+lfs/eaccelerator.so" 
eaccelerator.shm_size="16" 
eaccelerator.cache_dir="/tmp/eaccelerator" 
eaccelerator.enable="1" 
eaccelerator.optimizer="1" 
eaccelerator.check_mtime="1" 
eaccelerator.debug="0" 
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.allowed_admin_path="/var/www/control.php"

创建cache缓存目录

eaccelerator.cache_dir="/var/cache/eaccelerator"   这里定义cache路径

默认值是/tmp/eaccelerator,这非常简单因为任何人都对该目录可写,但是并不明智,因为重启后系统会自动清理该目录。一个更好的地方是/var/cache/eaccelerator。创建该目录并确保它对eAccelerator的使用者可写(通常该用户是你的网络服务器运行者,可能是www-data)。 使用默认值的话这样继续:

mkdir /tmp/eaccelerator
chmod 777 /tmp/eaccelerator

改成 /var/cache/eaccelerator的话这样继续,先改php.ini

eaccelerator.cache_dir="/var/cache/eaccelerator" 
sudo mkdir /var/cache/eaccelerator
sudo chown root:www-data /var/cache/eaccelerator
sudo chmod u=rwx,g=rwx,o= /var/cache/eaccelerator

复制控制文件control.php到网站根目录

sudo cp control.php /var/www/

修改control.php的$user和$pw,默认是admin和eAccelerator

sudo vi /var/www/control.php 

重启lighttpd

sudo /etc/init.d/lighttpd restart

打开 http://localhost/control.php

eAccelerator control.php页面

查看之前的info.php页面,有下列字段:

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
    

ROR+MySQL

安装

sudo apt-get install ruby ruby1.8-dev rubygems 
sudo apt-get install mysql-server mysql-client  #中途需要输入root用户密码
sudo gem install mysql 
sudo gem install rails
sudo apt-get install  libfcgi-dev libfcgi-ruby1.8 

配置