ICE的通讯结构:
ICE有分为提供服务的一方Server和寻求服务的一方Client,两台机子上都需要安装ICE组件,他们的通信结构如上图
Client端应该事先知道Server端能提供的服务是什么,有什么格式?这就是图中的Proxy Code,在Proxy Code中定义好了类和接口。Server端中接口定义的就是
Skeleton,具体实现接口的是Server Application,Server Application可以是C++,java,C#等写的,但是ICE不提供PHP写Server端。
ICE安装方式:
1.redhat5:(ice3.4.2) yum源安装
01.download: cd /etc/yum.repos.d/ wget https://zeroc.com/download/Ice/3.4/rhel5/zeroc-ice.repo
如果无法下载以上地址,可能使被墙了,试试:wget http://www.zeroc.com/download/Ice/3.4/rhel5/zeroc-ice.repo
zeroc-ice.repo的内容为:
[zeroc-ice]
name=Ice 3.4 for RHEL $releasever - $basearch
baseurl=http://www.zeroc.com/download/Ice/3.4/rhel$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=http://www.zeroc.com/download/RPM-GPG-KEY-zeroc-release
02.编辑zeroc-ice.repo:
[zeroc-ice]
name=Ice 3.4 for RHEL $releasever - $basearch
baseurl=http://www.zeroc.com/download/Ice/3.4/rhel5/$basearch
enabled=1
gpgcheck=1
gpgkey=http://www.zeroc.com/download/RPM-GPG-KEY-zeroc-release
03.查看 yum list ice* db46* mcpp-devel 或 yum list ice* db48* mcpp-devel(官方)
04.安装 yum install ice* db46* mcpp-devel 或 yum list ice* db48* mcpp-devel(官方)
05.emacs /etc/php.d/ice.ini 内容:extension=IcePHP.so
06.修改php.ini extension=IcePHP.so 并把IcePHP.so复制到extentsion_dir中
注意:这种方法的IcePHP.so module是官方编译的,只能适合官方指定的php版本:这里是php5.1.6
2.redhat5:(ice3.4.2) 编译安装64位(注意我的是64位操作系统,32位安装没有什么特别的地方)
附上官方安装说明:
This source distribution only supports building Ice for PHP as a dynamic PHP extension; the product of the build is a shared library
that you must configure PHP to load. Follow the steps below to build Ice for PHP:
1. Change to Ice for PHP source subdirectory.
> cd Ice-3.4.2/php
2. Edit config/Make.rules and review the build settings. For example, you may want to enable OPTIMIZE. If your PHP installation resides
in a non-standard location, modify the PHP_HOME setting to contain the installation directory. If you are using PHP 5.3 or later and
wish to use PHP namespaces, set USE_NAMESPACES=yes.
3. If you have not built Ice for C++ from the cpp subdirectory, then set the ICE_HOME environment variable to the directory containing
your Ice installation. For example, if Ice is installed in /opt/Ice-3.4.2, set ICE_HOME as follows: $ export ICE_HOME=/opt/Ice-3.4.2
If you installed Ice using RPMs, set ICE_HOME as shown below:
$ export ICE_HOME=/usr
3. Run make.
说明:如果按照官方来安装是不可能安装成功的,从安装步骤编号1233就可以看出官方安装说明写得有多草率!
我的安装记录:
下载源码安装包Ice-3.4.2.tar.gz和第三方依赖包ThirdParty-Sources-3.4.2.tar.gz(官网有下载连接,这里就不贴了,一定要求去官网下载)
先解压ThirdParty-Sources-3.4.2.tar.gz : tar –xvf ThirdParty-Sources-3.4.2.tar.gz
Cd ThirdParty-Sources-3.4.2
安装 mcpp-2.7.2:
tar -xvf mcpp-2.7.2.tar.gz
cd mcpp-2.7.2
./configure --prefix=/usr/local/ICE-3.4.2/mcpp-2.7.2/ CFLAGS=-fPIC --enable-mcpplib --disable-shared
make
make install
...On 64-bit platforms, after installation it is necessary to rename the
library installation directory from $(prefix)/lib to $(prefix>/lib64.(这句话是说把安装的mcpp目录中的lib目录名改成lib64,32位无需改动)
安装Berkeley DB:
tar -xvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix/
../dist/configure --prefix=/usr/local/ICE-3.4.2/BerkeleyDB.4.6/ --enable-cxx
make
make install
...On 64-bit platforms, after installation it is necessary to rename the
library installation directory from $(prefix)/lib to $(prefix>/lib64.(这里也要把lib—> lib64)
安装bzip2:
cd ../../
tar -xvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
//32位机器:Makefile PREFIX=/usr/local/ICE-3.4.2/bzip2-1.06
//64位机器:make -f Makefile-libbz2_so
make
make install PREFIX=/usr/local/ICE-3.4.2/bzip2-1.06
...On 64-bit platforms, after installation it is necessary to rename the
library installation directory from $(prefix)/lib to $(prefix>/lib64. (这里也要把lib—> lib64)
安装expat:
cd ..
tar -xvf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --prefix=/usr/local/ICE-3.4.2/expat-2.0.1/
make
make install
...On 64-bit platforms, after installation it is necessary to rename the
library installation directory from $(prefix)/lib to $(prefix>/lib64. (这里也要把lib—> lib64)
安装oppenssl:
cd ..
tar -xvf openssl-0.9.8r.tar.gz
cd openssl-0.9.8r
./config --prefix=/usr/local/ICE-3.4.2/openssl
make
make install
//好像不需要改成lib64,(这里我没改lib64就安装成功了,注意每次重新安装的时候记得先清理一下:make clean)
redhat5.7在默认情况下会在usr/lib中搜索*.so,但在64位系统中*.so在usr/lib64和usr/local/lib64中,故要将包含对应xx.so文件拷贝到usr/lib中,更简单的做法是加入到LD_LIBRARY_PATH变量中,如下面/etc/profile的修改
没有报错安装完成Ice3.4.2
修改/etc/profile:在尾部加上
export PHPPATH=/wdxy/ICE-3.4.2/Ice-3.4.2/php/:
export ICE_HOME=/wdxy/ICE-3.4.2/Ice-3.4.2
export PATH=$PATH:$ICE_HOME/bin
export LD_LIBRARY_PATH=$ICE_HOME/lib64:/usr/local/ICE-3.4.2/expat-2.0.1/lib64:$LD_LIBRARY_PATH
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC ICE_HOME
编译生成动态库IcePHP.so
cd ../php
emacs config/Make.rule.php四处:
prefix ?= /wdxy/ICE-3.3.0/Ice-$(VERSION)
embedded_runpath_prefix ?= /wdxy/ICE-3.3.0/Ice-$(VERSION_MAJOR).$(VERSION_MINOR)
PHP_HOME ?= /home/ap/php5.2 //注意是PHP_HOME目录,不是bin/php 或php执行文件的路径(我在这里坑了半天,报unkown php version ) 后面会附上php5.2.17 php-fpm的安装
LP64 := yes
make
make install
将会在/wdxy/ICE-3.3.0/Ice-$(VERSION)目录下生成php文件夹,内有IcePHP.so文件,拷贝到对应php的extension_dir下
php -i | grep extension_dir 查看extension_dir
修改php.ini文件:
[Ice]
include_path = "/home/ap/php5.2/lib/php:/wdxy/ICE-3.4.2/Ice-3.4.2/php"
extension=IcePHP.so
php -m 可以看到ice模块的存在表示安装成功
Icephp安装配置完成
Nginx + php5.2.17 + php-fpm的安装(php-fpm在php5.3以后才是php的内置模块)
http://us.php.net/distributions/php-5.2.17.tar.gz
http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
http://nginx.org/download/nginx-1.8.1.tar.gz
tar -xvzf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | sudo patch -d php-5.2.17 -p1
cd php-5.2.17
./configure --prefix=/home/ap/php5.2 -enable-fastcgi -with-config-file-path=/home/ap/php5.2/etc -with-openssl -enable-fpm -enable-mbstring -with-freetype-dir -with-jpeg-dir -with-png-dir -with-zlib-dir -with-libxml-dir -enable-xml -with-mhash -enable-pcntl -enable-sockets -with-bz2 -with-curl -with-curlwrappers -enable-mbregex -with-gd -enable-gd-native-ttf -enable-zip -enable-soap -with-iconv -enable-bcmath -enable-shmop -enable-sysvsem -enable-inline-optimization -with-ldap -with-ldap-sasl -enable-pdo
注:这里我没有安装mysql模块,你可以选择的加上mysql模块
可能用到的依赖:
yum install openldap openldap-devel -y
cp -frp /usr/lib64/libldap* /usr/lib/
yum install libmcrypt libmcrypt-devel
yum install mhash-devel
make
make install
安装php成功
查看php.ini的路径 php –i | grep php.ini
从源码中拷贝一份到对应的目录中
cp sapi/cgi/fpm/php-fpm /etc/init.d/
chmod +x /etc/init.d/php-fpm
cp /usr/src/php-5.2.17/php.ini-recommended /usr/local/lib/php.ini
mkdir /etc/php/
ln -s /usr/local/lib/php.ini /etc/php/php.ini
ln -s /usr/local/etc/php-fpm.conf /etc/php/php-fpm.conf
安装php5.2 + php-pmp成功
/etc/init.d/php-fpm5.2.17 start
/etc/init.d/php0fpmt.3.17 stop
ps -ef|grep php
安装nginx
tar -xvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure --prefix=/wdxy/nginx --user=nobody --group=nobody --with-http_ssl_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-pcre
yum install pcre
yum install pcre-devel
cd sbin
./ngix启动
./nginx -s reload重新加载
ps -ef|grep nginx
最后附上nginx.conf:
#user nobody;
#worker_processes 1;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
#listen 80
listen 8054 default backlog=1024;
server_name localhost;
#server_name webim.whwdxy.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.php index.jsp;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
#root html/webim.whwdxy.com;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
# add 7 line
fastcgi_read_timeout 300;
fastcgi_buffers 8 128k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
php-fpm.conf:
<?xml version="1.0" ?>
<configuration>
All relative paths in this config are relative to php's install prefix
<section name="global_options">
Pid file
<value name="pid_file">/home/ap/php5.2/logs/php-fpm.pid</value>
Error log file
<value name="error_log">/home/ap/php5.2/logs/php-fpm.log</value>
Log level
<value name="log_level">notice</value>
When this amount of php processes exited with SIGSEGV or SIGBUS ...
<value name="emergency_restart_threshold">10</value>
... in a less than this interval of time, a graceful restart will be initiated.
Useful to work around accidental curruptions in accelerator's shared memory.
<value name="emergency_restart_interval">1m</value>
Time limit on waiting child's reaction on signals from master
<value name="process_control_timeout">5s</value>
Set to 'no' to debug fpm
<value name="daemonize">yes</value>
</section>
<workers>
<section name="pool">
Name of pool. Used in logs and stats.
<value name="name">default</value>
Address to accept fastcgi requests on.
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
<value name="listen_address">127.0.0.1:9000</value>
<value name="listen_options">
Set listen(2) backlog
<!-- <value name="backlog">-1</value> -->
<value name="backlog">1024</value>
Set permissions for unix socket, if one used.
In Linux read/write permissions must be set in order to allow connections from web server.
Many BSD-derrived systems allow connections regardless of permissions.
<value name="owner"></value>
<value name="group"></value>
<value name="mode">0666</value>
</value>
Additional php.ini defines, specific to this pool of workers.
<value name="php_defines">
<!-- <value name="sendmail_path">/usr/sbin/sendmail -t -i</value> -->
<!-- <value name="display_errors">0</value> -->
</value>
Unix user of processes
<value name="user">nobody</value>
Unix group of processes
<value name="group">nobody</value>
Process manager settings
<value name="pm">
Sets style of controling worker process count.
Valid values are 'static' and 'apache-like'
<value name="style">static</value>
Sets the limit on the number of simultaneous requests that will be served.
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
<value name="max_children">500</value>
Settings group for 'apache-like' pm style
<value name="apache_like">
Sets the number of server processes created on startup.
Used only when 'apache-like' pm_style is selected
<value name="StartServers">20</value>
Sets the desired minimum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name="MinSpareServers">5</value>
Sets the desired maximum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name="MaxSpareServers">35</value>
</value>
</value>
The timeout (in seconds) for serving a single request after which the worker process will be terminated
Should be used when 'max_execution_time' ini option does not stop script execution for some reason
'0s' means 'off'
<value name="request_terminate_timeout">0s</value>
The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
'0s' means 'off'
<value name="request_slowlog_timeout">0s</value>
The log file for slow requests
<value name="slowlog">logs/slow.log</value>
Set open file desc rlimit
<value name="rlimit_files">1024</value>
Set max core size rlimit
<value name="rlimit_core">0</value>
Chroot to this directory at the start, absolute path
<value name="chroot"></value>
Chdir to this directory at the start, absolute path
<value name="chdir"></value>
Redirect workers' stdout and stderr into main error log.
If not set, they will be redirected to /dev/null, according to FastCGI specs
<value name="catch_workers_output">yes</value>
How much requests each process should execute before respawn.
Useful to work around memory leaks in 3rd party libraries.
For endless request processing please specify 0
Equivalent to PHP_FCGI_MAX_REQUESTS
<value name="max_requests">1500</value>
Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)
Makes sense only with AF_INET listening socket.
<value name="allowed_clients">127.0.0.1</value>
Pass environment variables like LD_LIBRARY_PATH
All $VARIABLEs are taken from current environment
<value name="environment">
<value name="HOSTNAME">$HOSTNAME</value>
<value name="PATH">/usr/local/bin:/usr/bin:/bin</value>
<value name="TMP">/tmp</value>
<value name="TMPDIR">/tmp</value>
<value name="TEMP">/tmp</value>
<value name="OSTYPE">$OSTYPE</value>
<value name="MACHTYPE">$MACHTYPE</value>
<value name="MALLOC_CHECK_">2</value>
</value>
</section>
</workers>
</configuration>
上面两个配置文件仅供参考。Nginx可以同时配置多版本的php同时运行,满足不同项目的需求:可参考http://blog.csdn.net/21aspnet/article/details/47658127