编译安装 Hiawatha v7.3 通过 

很早就听说了hiawatha,就是一直没有时间去尝试.最近我的vps内存是越来越吃紧,于是更换掉之前的巨无霸软件就成了当务之急,从而去追求一些轻量级的serverd.

我用varnish 替换了 squid,待会还要用vsftpd 替换 proftpd.

最近越来越不能忍受cherokee的巨大,tar 包居然达到了 6M之多.cherokee 固然是好东西,但是内存状况不允许我这样做.故而相中了号称轻量至极的hiawatha web server.源码包才100多Kb……

下载最新版本7.3的源码包,解压,进入目录
我的configure:
[root@PowerPC hiawatha-7.3]# ./configure \
> --prefix=/usr/local/hiawatha \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig/hiawatha \
> --localstatedir=/var \
> --disable-largefile \
> --disable-ipv6 \
> --disable-ssl \
> --disable-xslt

检查依赖,没有问题.紧接着 make && make install 编译和安装.hiawatha 果然够轻量级,几乎不到十秒就完成了.棒阿

进入配置文件目录 /etc/sysconfig/hiawatha/下,编辑 hiawatha.conf.
可以说hiawatha的配置格式非常简单,而且还有其中例子可以参考.

我的部分配置:

ServerId = http

Binding {
Port = 81
}

FastCGIserver {
FastCGIid = PHP5
ConnectTo = 127.0.0.1:9000
Extension = php, php5
SessionTimeout = 30
}

#适用于wordpress的地址重写
UrlToolkit {
ToolkitID = wp
Match ^/index\.php/.*$ Rewrite /index.php?$1
}

VirtualHost {
Hostname = xiazhengxin.cn
WebsiteRoot = /home/http/xiazhengxin_cn
StartFile = index.php
# ExecuteCGI = yes
UseFastCGI = PHP5
UseToolkit = wp
}


主文件配置完成后,如果用到了fastcgi的话,还要编辑下同目录下php-fcgi.conf 文件.

Server = <php-cgi executable>;<binding>;<UID>[:<GIDs>][;<PHP configuration file>]
这样的格式定义好fastcgi 位置.

如我的:
Server = /usr/local/sbin/php-fpm ; 127.0.0.1:9000 ; http:web


更多配置参见:http://www.hiawatha-webserver.org/howto/cgi_and_fastcgi

一切完成后,hiawatha -k 测试配置文件.
没有问题后,hiawatha 启动服务器.
[ ] ( 1771 次浏览 ) 永久链接 ( 3 / 2714 )
编译安装 nginx/0.8.50 与 lighttpd/1.4.28 通过 

做好了varnish cache 缓存服务器,现在搞定几个后置服务器.
cherokee 还是我的主服务器,跑 php-cgi 程序,我打算用nginx 作为静态资源服务器,而lighttpd 则分流一部分的php-cgi程序.至于tomcat 则是跑 java 程序。

这样一来就很清楚了,于是今天便动手编译nginx 和 lighttpd.

下载各自的最新版本,解压,进入目录

先是nginx,最新的开发版 0.8.50

我的configure:
[root@PowerPC nginx-0.8.50]# ./configure \
> --prefix=/usr/local/nginx \
> --sbin-path=/usr/local/sbin/nginx \
> --conf-path=/etc/sysconfig/nginx/nginx.conf \
> --error-log-path=/var/log/nginx/error.log \
> --pid-path=/var/nginx.pid \
> --lock-path=/var/nginx.lock \
> --user=http \
> --group=web \
> --with-select_module \
> --with-poll_module \
> --with-file-aio \
> --with-http_flv_module \
> --with-http_gzip_static_module \
> --without-http_ssi_module \
> --without-http_auth_basic_module \
> --without-http_geo_module \
> --without-http_map_module \
> --without-http_referer_module \
> --without-http_rewrite_module \
> --without-http_proxy_module \
> --without-http_fastcgi_module \
> --without-http_uwsgi_module \
> --without-http_scgi_module \
> --without-http_upstream_ip_hash_module \
> --http-log-path=/var/log/nginx/access.log \
> --http-client-body-temp-path=/tmp/nginx/request.tmp \
> --without-mail_pop3_module \
> --without-mail_imap_module \
> --without-mail_smtp_module \
> --without-pcre

检查依赖,一切顺利.接下来make && make install.速度也很快。

很快安装好了.

编辑生成的 nginx.conf (位于/etc/sysconfig/nginx 下),因为我是用来做纯静态资源服务器的,所以删除了一切关于cgi/scgi/fcgi 之类的配置,只是做了几个virtualhost 而已.

server {
listen 83;
server_name xiazhengxin.tk;
charset utf-8;
root /home/http/xiazhengxin_tk/;
index index.html index.htm;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 83;
server_name xiazhengxin.net.cn;
charset utf-8;
root /home/http/xiazhengxin_net_cn/;
index index.html index.htm;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}


配置完成后,nginx -t 测试一下,ok.

运行nginx 启动服务器.

试图从浏览器访问,失败.

查看日志文件(/var/log/nginx/error.log),发现里面出现了

2010/09/12 13:09:09 [emerg] 28358#0: eventfd() failed (38: Function not implemented)
2010/09/12 13:09:09 [alert] 28357#0: worker process 28358 exited with fatal code 2 and can not be respawn


这样的字样,搜索了一下 eventfd() 函数,发现是File AIO在作怪.

而aio 只在高版本的linux kernel 上才支持.
Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only

而我的centos 内核是:
Linux PowerPC 2.6.18-128.2.1.el5.028stab064.4 #1 SMP Mon Jul 27 12:45:01 MSD 2009 i686 i686 i386 GNU/Linux

好吧,我情绪稳定.

去掉 --with-file-aio 参数.重新编译安装nginx.
这次没问题了(同样的配置下).

接下是lighttpd,我的cofnigure:
[root@PowerPC lighttpd-1.4.28]# ./configure \
> --prefix=/usr/local/lighttpd \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig/lighttpd \
> --localstatedir=/var \
> --enable-lfs=no \
> --disable-ipv6 \
> --without-mysql \
> --without-ldap \
> --with-attr \
> --without-openssl \
> --without-kerberos5 \
> --with-zlib \
> --with-bzip2 \
> --without-fam \
> --without-webdav-props \
> --without-webdav-locks \
> --without-gdbm \
> --with-memcache \
> --without-lua

依赖没有问题,然后 make && make install. 编译 安装至指定目录.
接下来复制源码包中doc文件夹下的config 里面的所有配置文件到/etc/sysconfig/lighttpd下.

稍加编辑即可.我主要是启用了mod_simple_vhost、mod_fastcgi、mod_compress 几个模块.
接着编辑conf.d目录下的对应文件即可.

配置完成后,测试一下
lighttpd -f lighttpd.conf -t 测试通过.
即可启动服务器.
lighttpd -f lighttpd.conf 启动.
[ ] ( 2247 次浏览 ) 永久链接 ( 3.1 / 2476 )
编译安装 Varnish Cache 2.1.3 通过 

前端时间,squid 爆了漏洞,心里感觉还是不能情绪稳定.最近又看到了varnish 这款http 缓存服务器的崛起,觉得很是棒.

再者说,squid 本不是专业反向代理服务器(服务端缓存),而是正向代理服务器(客户端缓存).而varnish cache 则是专业做反向代理的。这是其一.

再者,squid 的体积越来越大,这是我不敢想的。源码压缩包 3M多,解压后竟达10多M...

再看varnish 则小巧了许多.不要1M.解压后才3M多.而且在内存占用方面,varnish 更是让我这台512M 的vps 轻松的多。

最后一点,varnish 的效率据说高于squid.有这么多的理由,我便干掉了squid,投奔varnish了.

下载最新版本 2.1.3 的源码包,解压,进入目录
我的configure:
[root@PowerPC varnish-2.1.3]# ./configure \
> --prefix=/usr/local/varnish \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig/varnish \
> --localstatedir=/var \
> --enable-shared=yes \
> --enable-static=no \
> --disable-largefile

检查依赖,一切OK.接下来 make && make install.
编译时间很快,比起squid 真是快了几倍。呵呵

编辑自动生成的default.vcl 配置文件,这里要说一下,不同于一下配置文件的格式,varnish 使用的是一个叫VCL (Varnish Confingure Language)的语言作为配置文件。囧rz 其实就是一些很简单的条件判断语句什么 if else 之类的.
更不会有switch 之类的,只要你写过一点程序,这些都不是难题.

为了让用户更好的编辑VCL文件,varnish 还提供了用于VIM 的语法高亮文件.
地址:http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/~checkout~/packages/vim-syntax-vcl/vcl.vim

下载放到指定目录即可.

接下开始编辑配置文件,按照官方的wiki提示,
新建几台后置服务器,分别运行于不同端口.

比如我的vps 有cherokee、nginx、lighttpd、tomcat 等.

backend to_cherokee {
.host = "127.0.0.1";
.port = "81";
}

backend to_lighttpd {
.host = "127.0.0.1";
.port = "82";
}

backend to_nginx {
.host = "127.0.0.1";
.port = "83";
}

backend to_tomcat {
.host = "127.0.0.1";
.port = "84";
}


再根据不同的域名转发到对应的后置服务器,

if (req.http.host ~ "^(\w*.)?xiazhengxin.cn$") {
set req.backend = to_cherokee;
}

if (req.http.host ~ "^(\w*.)?xiazhengxin.tk$") {
set req.backend = to_nginx;
}

if (req.http.host ~ "^(\w*.)?xiazhengxin.org.cn$") {
set req.backend = to_lighttpd;
}

if (req.http.host ~ "^(\w*.)?xxx.xxx$") {
set req.backend = to_tomcat;
}


上段代码须放入sub vcl_recv {} 块中.

当然还可以自定义错误.编辑 sub vcl_error {} 块即可.

更多配置详见:http://www.varnish-cache.org/trac/wiki/VCL

这里还有一些例子可供参考:
http://www.varnish-cache.org/trac/wiki/VCLExamples

一切配置完成后,运行 varnishd 启动服务器.
报错:
varnishstat: error while loading shared libraries: libvarnish.so.1: cannot open shared object file: No such file or directory


运行ldconfig 即可.

再次运行
[root@PowerPC varnish]# varnishd -a :80 -f default.vcl -u http
启动成功.
[ ] ( 2680 次浏览 ) 永久链接 ( 3 / 2577 )
编译安装 eAccelerator revision 427 for php 通过 

想到自己自从编译安装了php 5.3.3 以来还没有为它安装个缓存器,于是今天便动手了.

先从svn 里面签出最新版本 svn --username anonymous --password anonymous co http://dev.eaccelerator.net/eaccelerator/trunk eaccelerator

svn: Repository moved temporarily to 'https://svn.eaccelerator.neteaccelerator/trunk'; please relocate

提示地址更换,囧rz 怎么官网地址没更新呢

更换地址再次签出,svn --username anonymous --password anonymous co https://svn.eaccelerator.net/eaccelerator/trunk eaccelerator
成功.

进入目录,phpize 生成 configure 文件.
我的configure:
[root@PowerPC eaccelerator]# ./configure \
> --prefix=/usr/local/php/eaccelerator \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig \
> --localstatedir=/var \
> --enable-eaccelerator \
> --enable-static=no

检查依赖,没有问题.make && make install 编译安装.

接下来让php 载入 eaccelerator.so 模块.
编辑/etc/php.ini

插入一下内容:
zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20090626/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"

注:更多设置,参见 http://www.eaccelerator.net/wiki/Settings

保存,killall php-fpm 杀掉所有php-fpm 进程.
再次启动php-fpm 即可.
注:/tmp/eaccelerator 目录我已经有了。且确保可写入.

查看版本信息:
[root@PowerPC ~]# php-fpm -v
PHP 5.3.3 (fpm-fcgi) (built: Jul 31 2010 11:36:42)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with eAccelerator v1.0-dev, Copyright (c) 2004-2010 eAccelerator, by eAccelerator

一切正常,安装完成.
[ ] ( 4296 次浏览 ) 永久链接 ( 3 / 2621 )
编译安装 Wine 1.3.1 通过 

昨天吧,wine 开发组发布了 wine 1.3.x 的开发版.而我还在使用之前编译的1.1.44.
而官方源里面也早已是稳定版 1.2 了.

所以我便打算,升级一下我的wine.

下载源码包,解压,进入目录

我的configure:
sharl@sharl-laptop:~/下载/wine-1.3.1$ ./configure \
> --prefix=/usr/local/wine \
> --exec-prefix=/usr/local \
> --sysconfdir=/etc/sysconfig \
> --localstatedir=/var \
> --disable-win16 \
> --disable-tests \
> --disable-largefile \
> --with-x

检查依赖,wine 基本没有什么必须的外部依赖.它所需的大部分依赖也全都自带了.这也是为什么wine 的源码包体积如此之大的原因.

检查完依赖后,运行 make 进行编译。这个时间会非常的长.我机器3G内存也用了大概十几分钟.好在我已经习惯了.

编译完成后,make install 安装至指定目录.

最后运行 winecfg 设置一下(比如安装Gecko、生成driver_c 路径等)即可.
[ ] ( 2567 次浏览 ) 永久链接 ( 3 / 2498 )

<< <上一页 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 下一页> >>