ICE的通信結構:php
ICE有分爲提供服務的一方Server和尋求服務的一方Client,兩臺機子上都須要安裝ICE組件,他們的通訊結構如上圖html
Client端應該事先知道Server端能提供的服務是什麼,有什麼格式?這就是圖中的Proxy Code,在Proxy Code中定義好了類和接口。Server端中接口定義的就是java
Skeleton,具體實現接口的是Server Application,Server Application能夠是C++,java,C#等寫的,可是ICE不提供PHP寫Server端。node
ICE安裝方式:mysql
1.redhat5:(ice3.4.2) yum源安裝react
01.download: cd /etc/yum.repos.d/ wget https://zeroc.com/download/Ice/3.4/rhel5/zeroc-ice.reponginx
若是沒法下載以上地址,可能使被牆了,試試:wget http://www.zeroc.com/download/Ice/3.4/rhel5/zeroc-ice.repoweb
zeroc-ice.repo的內容爲:sql
[zeroc-ice]apache
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
tar -xvf Ice3.4.2.tar.gz
cd Ice3.4.2/cpp
emacs(or vim) conf/Make.rules
將剛剛安裝的全部的第三方依賴包的路勁填入
如: BZIP2_HOME ?= /usr/local/ICE-3.4.2/bzip2-1.0.6
填完後保存 make ; make install
沒有報錯安裝完成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
source /etc/profile
運行: icegridnode -v
3.4.2 (安裝成功)
編譯生成動態庫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
耗費了我兩天時間,呼呼