php服务模块在nginx中的安装,Nginx和Nginx_http_push_module模块安装和设置方法

一.

Nginx和nginx_http_push_module模块安装及部署:

1.

到http://nginx.org/en/download.html 下载nginx-0.8.53.tar.gz

到 http://pushmodule.slact.net/#download 下载

nginx_http_push_module模块

到 http://www.pcre.org/下载pcre(正则表达式) 函数库源代码

2.

上传到”/home/你的用户名”目录中,并解压缩:

tar -zxvf nginx-0.8.53.tar.gz.

tar -zxvf nginx_http_push_module-0.692.tar.gz

tar –zxvf pcre-8.10.tar.gz

3.若你的linux中没有安装C编辑器gcc和C++编辑器g++,则用以下命令安装:

sudo apt-get install gcc

sudo apt-get install g++

若已安装,则跳过该步骤.

4.需要安装2个C函数库:

4.1 pcre(正则表达式) ,编译安装:

./configure

make

sudo make install

4.2 SSL: apt-get install libssl-dev

5.解压后,进入/home/你的用户名/nginx-0.8.53目录

6.安装Nginx:

./configure  –add-module=../nginx_http_push_module-0.692

–with-cc-opt=’-O2′

7. 编译Nginx:

make

8.编译安装:

sudo make install

二.   安装php和mysql:

sudo apt-get install php5-cli php5-cgi mysql-server

php5-mysql

三.   FastCgi/php5-fpm(二选一):

1.  安装FastCgi :

sudo apt-get install spawn-fcgi

启动:

spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f

/usr/bin/php-cgi

2.       安装php5-fpm:

1)       下载:

sudo apt-get install php5-fpm

2)

修改/etc/php5/fpm/pool.d/www.conf中的pm.max_children=50

和request_terminate_timeout = 1200

3)       启动php-fpm:

/etc/init.d/php5-fpm start

四.   修改nginx_http_push模块的配置和测试:

1.       修改nginx.conf:

1.1   worker_processes  10;

1.2   event部分加入  use epoll;

1.3   http部分加入:

fastcgi_connect_timeout 1200;

fastcgi_send_timeout 1200;

fastcgi_read_timeout 1200;

fastcgi_buffer_size 128k;

fastcgi_buffers 8 128k;

fastcgi_busy_buffers_size 128k;

fastcgi_temp_file_write_size 128k;

push_max_reserved_memory 10M;

并修改 keepalive_timeout  615;

1.4  server部分加入:

location /Microsoft-Server-ActiveSync {

root html;

if ($args ~ Cmd=Ping){

rewrite /Microsoft-Server-ActiveSync /activity last;

}

rewrite /Microsoft-Server-ActiveSync /z-push/index.php last;

}

location /publish {

set $push_channel_id $arg_user; #/?id=239aff3 or somesuch

push_publisher;

push_store_messages on; # enable message queueing

push_message_timeout 2h; # expire buffered messages after 2

hours

push_max_message_buffer_length 10; # store 10 messages

#push_min_message_recipients 0; # minimum recipients before

purge

}

# public long-polling endpoint

location /activity {

push_subscriber;

# how multiple listener requests to the same channel id are

handled

# – last: only the most recent listener request is kept, 409 for

others.

# – first: only the oldest listener request is kept, 409 for

others.

# – broadcast: any number of listener requests may be

long-polling.

push_subscriber_concurrency broadcast;

set $push_channel_id $arg_user;

default_type text/plain;

}

2         启动nginx:

/usr/local/nginx/sbin/nginx

3         测试:

4         地址栏中输入http://localhost/Microsoft-Server-ActiveSync?Cmd=Ping&user=osa

5

浏览器会处于等待状态,等待Ping返回一个值

6         在linux的命令行中输入

telnet 127.0.0.1 80

7         并输入测试

8         POST

/publish?user=osa HTTP/1.0

8Content-Length: 1

a

(以上为一段完整测试代码)

9

测试结果:浏览器会呈现一个字符a,即测试成功

10       停止Nginx:

11

/usr/local/nginx/sbin/nginx –s stop

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值