设为首页收藏本站

数码鹭岛论坛

 找回密码
 注-册

QQ登录

只需一步,快速开始

搜索
查看: 7740|回复: 1
打印 上一主题 下一主题

Zeus+php+Zend Optimizer for Linux安装指南

[复制链接]
跳转到指定楼层
1#
发表于 2008-9-26 17:53:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Zeus+php+Zend Optimizer for Linux安装指南

本文是Crossday第一篇unix作文,基于linux而写出。zeus是一个著名的web服务器软件,其效能远在apache1/2之上,是整台服务器用户跑论坛的首选,对内存小于1G而流量非常大的用户,换用zeus会比apache多获得一倍的负载能力。
本文提供方法在redhat linux 7.3及以上各版本,PHP 4.3.0及以上版本,Zend Optimizer 2.1.0验证通过,所配置参数为适应每15分钟在线1000人以上的,使用Discuz! 2.0/3.0的中大型论坛所优化

进入一个目录 如
cd /usr/local/src

找一个zeus 4.2 r3 for linux的破解版本下载
wget http://download.discuz.net/zeus_linux.tgz

tar xvzf zeus_linux.tgz
cd Zeus.Web.Server.v4.2r3.Linux.x86/
tar xvzf Zeus_42r3_Linux-glibc2.1.tgz
cd Zeus_42r3_Linux-glibc2.1/

开始安装
./zinstall

按CTRL+C 打入accept

Where should the product be installed? [/usr/local/zeus]: 回车

Installation options:

1. Full install of both admin server & web server
2. Stand-alone install of admin server
3. Clustered install of web server
H. Help

Choose installation option [1]: 回车

Enter the key filename, or leave blank for unlicensed mode: /usr/local/src/Zeus.Web.Server.v4.2r3.Linux.x86/license.key (输入密匙位置)

Please choose a password for the admin server: ****** (输入管理员密码)
Re-enter: ****** (重新输入密码)

Would you like Zeus to start at boot time? Y/N [Y]: (回车)

以上是安装过程 很容易的就装好了 如果有apache在跑 先把他停掉 避免80端口冲突
/usr/local/apache/bin/apachectl stop

若安装中提示libdb.so.2不存在 先进入压缩包的libdb.so.2目录中
rpm -ivh db1-1.85-8.i386.rpm

安装php
cd /usr/local/src
从小日本网站下载php
wget http://cn2.php.net/get/php-4.3.4.tar.gz/from/jp2.php.net/mirror
tar xvzf php-4.3.4.tar.gz
cd php-4.3.4/
./configure --prefix=/usr/local/php --enable-fastcgi --enable-force-cgi-redirect --with-config-file-path=/etc --with-zlib --with-mysql --with-xml
make
make install
cp php.ini-dist /etc/php.ini

安装Zend Optimizer
cd /usr/local/src
wget http://download.discuz.net/ZendOptimizer-2%5B1%5D.1.0b-Linux_glibc21-i386.tar.gz
tar xvzf ZendOptimizer-2%5B1%5D.1.0b-Linux_glibc21-i386.tar.gz
cd ZendOptimizer-2.1.0b-Linux_glibc21-i386/
./install.sh
一阵回车 问Confirm the location of your php.ini file的时候打入/etc
问Are you using Apache web server?的时候选No

设置Zeus
访问 http://your.com:9090 (你的域名地址或IP地址)
用户名 admin 密码:刚才设定的密码

进入Zeus管理控制台,点Create a Virtual Server 把相关的六个选项填好 不多说
提交后出现刚才加入的virtual server,点FastCGI

Enabling Support for FastCGI Programs 选 Enabled
Restricting FastCGI locations 选 Enable FastCGI programs to be located anywhere
Configuring Directories for FastCGI Local Responders 不用写他 因为我们用remote方式连接fastcgi

Configuring FastCGI Remote Responders 中填入以下配置
Directory name : /usr/local/php/bin/php
Location: Machine name: localhost
          Port: 8002
Additional methods supported?:None

其他都不用管,点Apply changes

点左边Url Handling下面的Handlers
File Extension : php
Specify the path and filename of the handler, relative to the document root : /usr/local/php/bin/php
点Apply changes

点左边Url Handling下面的Directory Requests
Index Files中加入一个 index.php 和一分隔逗号
Directory Listing选Disabled
点Apply changes

再点上面的 This configuration has been modified. Click here for details or to make it take effect.
出来的页面点Commit

配置php-fastcgi
cd /usr/local/zeus/rc.d
建立一个S05php的文件 内容为


  Code: [Copy to clipboard]   
#!/bin/sh

# Script to start and stop the persistent PHP runner for FastCGI.
# Please check paths before use.

# FastCGI PHP binary
FPHPBIN=/usr/local/php/bin/php

# Location to place semaphore
SEMFILE=/tmp/php.pid
PHP_FCGI_CHILDREN=200
PHP_FCGI_MAX_REQUESTS=1000
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS

# This is Linux - use /proc to increase the local (ephemeral) port range
#echo 1024 65000 >; /proc/sys/net/ipv4/ip_local_port_range

if [ -z "$ZEUSHOME" ]
then
  cd `dirname $0`/..
  ZEUSHOME=`pwd`
  export ZEUSHOME
fi

case "$1" in
  'start')

        if [ -e $SEMFILE ]
                then
                        echo FastCGI PHP error: already running.Restart FastCGI PHP now
                    kill `cat $SEMFILE`
            sleep 5
        fi

        if [ ! -x $FPHPBIN ]
                then
                        echo FastCGI PHP error: please check that $FPHPBIN is executable and exists.
                exit 1
        fi

                echo Starting FastCGI PHP.
                $ZEUSHOME/web/bin/fcgirunner --user=99 --group=99 --pidfile=$SEMFILE 8002 $FPHPBIN
        ;;

  'stop')
        if [ -e $SEMFILE ]
                then
                echo Stopping FastCGI PHP.
        kill `cat $SEMFILE`
        rm $SEMFILE
                exit 0
        fi
       ;;
  'restart')
        if [ -e $SEMFILE ]
                then
                echo Stopping FastCGI PHP.
                kill `cat $SEMFILE`
        sleep 5
        fi
        echo Starting FastCGI PHP.
        $ZEUSHOME/web/bin/fcgirunner --user=99 --group=99 --pidfile=$SEMFILE 8002 $FPHPBIN
       ;;
  *)
    echo "usage: $0 {start|stop|restart}"
    ;;

esac
exit 1

注意--user=65534 --group=65534 为php进程运行的用户和组,一般设置为nobody用户和组FreeBSD是65534/65534,Linux是99/99

如不会建文件 可看下面范例
vi S05php
(打一个小写的i)
(把上面的内容复制到剪贴板 然后按SHIFT+INSERT粘贴过去)
(按ESC)
(输入 :wq 然后回车)

改写属性使其可执行
chmod 755 S05php

回到Zeus的9090端口管理界面 把刚才设置的虚拟主机Start

启动Zeus的命令为 /usr/local/zeus/start-zeus
停止Zeus的命令为 /usr/local/zeus/stop-zeus
重启Zeus的命令为 /usr/local/zeus/restart-zeus

编辑/etc/rc.local
加入一行
/usr/local/zeus/start-zeus
使得Zeus在开机时自动运行

如果现在无法访问web,多半是因为没有把apache停掉造成的,注意要将启动时候的apache自启动给去掉 否则zeus无法绑定到80端口进而无法访问 如没有上述问题 安装后仍然无法访问 可能为web服务器没有正确安装 例如第一次安装后中断退出 第二次又以升级方式安装 等等 这样的情况建议先把zeus停掉 然后将其目录rm -fr删除 重新安装一次即可正常 个人以为这是zeus安装脚本设计的不合理所致

结束:zeus实在是太强大了,无以言表,在不需任何外挂模块的情况下实现多线程的高效服务 IP并发限制 来路限制 带宽限制等如此多丰富而实用的功能,确实是unix世界中极为强悍和高效的web服务器软件

S05php脚本为CCF的坛主hunrea所作

我的第一篇unix作文,不当指出敬请指正,欢迎转载,转载请注明出自 discuz.net
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享
2#
 楼主| 发表于 2008-9-26 18:15:15 | 只看该作者

Zeus 4.3+php+Zend Optimizer for Linux安装指南(第二版)

Zeus 4.3+php+Zend Optimizer for Linux安装指南(第二版)
之前我曾写过Zeus 4.2及PHP/ZO在Linux下的安装,目前Zeus已升级到4.3版本,加入了对Local FastCGI的类似suexec的支持,可谓一大增强。
本文基于linux而写出。zeus是一个著名的web服务器软件,其效能远在apache1/2之上,是整台服务器用户跑论坛的首选,对内存小于1G而流量非常大的用户,换用zeus会比apache多获得一倍的负载能力。
本文提供方法在redhat linux AS3,PHP 4.3.9,Zend Optimizer 2.5.5验证通过,所配置参数为适应每15分钟在线1000人以上的,使用Discuz! 2.0/3.0的中大型论坛所优化

上篇文章中我们使用Remote FastCGI的方式,通过调用8002端口实现Zeus+PHP的搭建,本文为了充分实现Zeus 4.3所具有的suexec功能,将把PHP安装为Local方式。

进入一个目录 如
cd /usr/local/src

找一个zeus 4.3 for linux的破解版本下载
wget http://download.discuz.net/Zeus_43_Linux-x86.tgz
wget http://download.discuz.net/Zeus_4.3_Linux_crack.zip

unzip Zeus_4.3_Linux_crack.zip #把破解包直接解压在/usr/local/src
tar xvzf Zeus_43_Linux-x86.tgz

cd Zeus_43_Linux-x86/

开始安装
./zinstall

按CTRL+C 打入accept

Where should the product be installed? [/usr/local/zeus]: 回车

Installation options:

1. Full install of both admin server & web server
2. Stand-alone install of admin server
3. Clustered install of web server
H. Help

Choose installation option [1]: 回车

Enter the key filename, or leave blank for unlicensed mode: /usr/local/src/license.key (这里的 key 是假的,真正的破解在之后覆盖二进制程序中进行)

Please choose a password for the admin server: ****** (输入管理员密码)
Re-enter: ****** (重新输入密码)

Would you like Zeus to start at boot time? Y/N [Y]: (回车)

以上是安装过程 很容易的就装好了 下面进行破解
cp -f /usr/local/src/zeus.web /usr/local/zeus/web/bin

如果有apache在跑 先把他停掉 避免80端口冲突
/usr/local/apache/bin/apachectl stop

安装php

cd /usr/local/src
感觉澳大利亚的会快一点(实际 200K/s 左右)
wget http://www.php.net/get/php-4.3.9.tar.gz/from/au.php.net/mirror
tar xvzf php-4.3.9.tar.gz
cd php-4.3.9/
./configure --prefix=/usr/local/php --enable-fastcgi --enable-force-cgi-redirect --with-config-file-path=/etc --with-zlib --with-mysql --with-xml
make
make install
cp php.ini-dist /etc/php.ini

安装Zend Optimizer
cd /usr/local/src
wget http://download.discuz.net/ZendOptimizer-2.5.5-linux-glibc21-i386.tar.gz
tar xvzf ZendOptimizer-2.5.5-linux-glibc21-i386.tar.gz
cd ZendOptimizer-2.5.5-linux-glibc21-i386
./install.sh
一阵回车 问Confirm the location of your php.ini file的时候打入/etc
问Are you using Apache web server?的时候选No

下面把Zeus自带的PHP换掉
rm /usr/local/zeus/php/php.zeus

给刚刚编译的PHP做一个符号连接
ln -s /usr/local/php/bin/php /usr/local/zeus/php/php.zeus

设置Zeus
访问 http://your.com:9090/ (你的域名地址或IP地址)
用户名 admin 密码:刚才设定的密码

进入Zeus管理控制台,点Create a Virtual Server 把相关的六个选项填好 不多说
注意:1. 指向的web目录要有权限读 2. 如果在 Host Name and Port 写域名,请确定该域名是绑定到当前IP的,否则请填写当前服务器IP地址

进入刚刚加入的virtual server,点Third Party中的PHP
Enabling PHP Support:选 Enabled

将 Specify the maximum number of PHP processes that should be created for each user:
由默认的 8 改为 5

将 Specify the maximum number of requests that an individual PHP process should handle. This prevents errant PHP processes from consuming too much memory.
由默认的 500 改为 200

其实这样仍然能够相应 5*200=1000个并发PHP请求了,足矣。
Apply Changes,然后点上面的 This configuration has been modified. Click here for details or to make it take effect.
然后 Commit

点左边Url Handling下面的Directory Requests
Index Files中的内容为 index.html, index.htm, index.shtml, index.cgi, index.php
如果不需要 index.shtml, index.cgi,可以将其去掉
!!重要!!下面的 Directory Listing,一定要Disabled,不然有安全问题。

回到Zeus的9090端口管理界面 把刚才设置的虚拟主机Start,放一个 phpinfo 进去,应该已经可以看到PHP装好了。

启动Zeus的命令为 /usr/local/zeus/start-zeus
停止Zeus的命令为 /usr/local/zeus/stop-zeus
重启Zeus的命令为 /usr/local/zeus/restart-zeus

如果安装的时候没有设定让Zeus开机自动启动,可编辑/etc/rc.local
加入一行
/usr/local/zeus/start-zeus
使得Zeus在开机时自动运行

今晚还有点时间,如果有兴趣,可以接着按下面的步骤装ZPS(Zend Performance Suite)。
cd /usr/local/src
wget http://download.discuz.net/ZendPerformanceSuite-3.6.0-Linux_glibc21-i386.tar.gz

下载一个可用的密匙
wget http://download.discuz.net/zend_performance_suite.dat

解压并安装
tar xvzf ZendPerformanceSuite-3.6.0-Linux_glibc21-i386.tar.gz
cd ZendPerformanceSuite-3.6.0-Linux_glibc21-i386
./install.sh --zeus

Search for a license file on my disk
输入刚才下载的key位置 /usr/local/src
剩下他自动给的参数都是对的,只要一路回车就可以

/usr/local/zeus/restart-zeus 重启一下 ZPS应该就装好了

事实上这次升级,Zeus 4.3+PHP这个组合最闪亮的地方在于FastCGI的权限设定,在虚拟主机的FastCGI设置中,具备了如下选项:
Owner of the requested file
Owner of the FastCGI executable
Owner of the document root
Specified uid / gid:
我们可以轻松的指定PHP运行的用户,配合php.ini中open_base限定到用户目录(如/home),可彻底解决Zeus 4.2中的FastCGI权限问题。

不当指出敬请指正,欢迎转载,转载请注明出自 Discuz!官方论坛 (http://www.discuz.net)/
您需要登录后才可以回帖 登录 | 注-册

本版积分规则

小黑屋|手机版|Archiver|数码鹭岛 ( 闽ICP备20006246号 )  

counter

GMT+8, 2025-12-3 13:51 , Processed in 0.073159 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表