免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: wangbin
打印 上一主题 下一主题

[FreeBSD] spawn-fcgi启动了512个php-cgi进程才可以 [复制链接]

论坛徽章:
54
2017金鸡报晓
日期:2017-02-08 10:39:42操作系统版块每日发帖之星
日期:2016-03-08 06:20:00操作系统版块每日发帖之星
日期:2016-03-07 06:20:00操作系统版块每日发帖之星
日期:2016-02-22 06:20:00操作系统版块每日发帖之星
日期:2016-01-29 06:20:00操作系统版块每日发帖之星
日期:2016-01-27 06:20:00操作系统版块每日发帖之星
日期:2016-01-20 06:20:00操作系统版块每日发帖之星
日期:2016-01-06 06:20:0015-16赛季CBA联赛之江苏
日期:2015-12-21 20:00:24操作系统版块每日发帖之星
日期:2015-12-21 06:20:00IT运维版块每日发帖之星
日期:2015-11-17 06:20:002015亚冠之广州恒大
日期:2015-11-12 10:58:02
21 [报告]
发表于 2009-11-12 22:10 |只看该作者
只是希望能用上。正准备ibm x3500,也许可以过把瘾。

论坛徽章:
0
22 [报告]
发表于 2009-11-17 09:02 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
23 [报告]
发表于 2009-11-17 09:04 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
24 [报告]
发表于 2009-11-17 10:41 |只看该作者
原帖由 ylshjx 于 2009-11-17 09:02 发表
nginx用起来很顺手啊,没有什么不正常的啊,xooass是DZ的吧,这个大的进程数需要相当大的内存的哦!


现在的客户新买机器的内存基本都在16G-32G,然后数据库也是另外的独立服务器,开1024个不是问题。

在资源足够的情况下,开大点可以杜绝偶然出现的502,何乐不为呢? 尽量不出问题客户才能安心,而不是介意要买多少内存

论坛徽章:
2
狮子座
日期:2013-08-26 15:25:32金牛座
日期:2013-09-05 15:45:36
25 [报告]
发表于 2009-11-18 15:51 |只看该作者
今天spawn-fcgi升级了
你们升了再看看呢

论坛徽章:
0
26 [报告]
发表于 2009-11-23 21:08 |只看该作者
原帖由 kisswen 于 2009-11-18 15:51 发表
今天spawn-fcgi升级了
你们升了再看看呢


十分感谢,我看看。

论坛徽章:
0
27 [报告]
发表于 2009-12-01 03:09 |只看该作者

故障依旧,不能解决。

spawn-fcgi 的php-cgi常常崩溃退出

论坛徽章:
0
28 [报告]
发表于 2010-02-19 07:42 |只看该作者
nginx用起来很顺手啊,没有什么不正常的啊,xooass是DZ的吧,这个大的进程数需要相当大的内存的哦!
ylshjx 发表于 2009-11-17 09:02



   
我使用i386的服务器也没有任何问题。

论坛徽章:
0
29 [报告]
发表于 2010-04-06 22:16 |只看该作者
基于CentOS 5.4搭建nginx+php+spawn-fcgi+mysql高性能php平台
发布: 2010-1-25 09:36 | 作者: apples | 来源: 雅狐网际
................................................

/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
mkdir -p /data/www/wwwroot
chmod +w /data/www/wwwroot
chown www:www /data/www/wwwroot -R
.............................

# vi init_php.ini
#!/bin/bash
fcgi_cf="/usr/local/php/etc/php.ini"
ea(){
cat << EOF
[eAccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="32"
eaccelerator.cache_dir="/data/cache/ea"
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"
EOF
}
#mkdir
mkdir -p /data/cache/ea
ea >> $fcgi_cf
#config for php.ini
sed -i '205 s#;open_basedir =#open_basedir = /data/www/wwwroot:/tmp#g' $fcgi_cf
sed -i '210 s#disable_functions =#;disable_functions = phpinfo,passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server#g' $fcgi_cf
sed -i '/expose_php/s/On/Off/' $fcgi_cf
sed -i '/display_errors/s/On/Off/' $fcgi_cf
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\nextension = "imagick.so"\n#' $fcgi_cf
sed -i 's#output_buffering = Off#output_buffering = On#' $fcgi_cf
2.5安装Zend
CODE:


#tar zvxf ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz
# cd ZendOptimizer-3.3.3-linux-glibc23-x86_64
# ./install
注:php.ini的位置为/usr/local/php/etc 服务器不选用apache
三、配置整合
3.1 配置nginx
注:本文spawn-fcgi开启9000跟9001两个端口,利用nginx的upstream负载均衡php程序到不同的fcgi端口上面,解决502 gateway错误
#cd /usr/local/nginx/conf
#cp nginx.conf nginx.conf.linuxtone
#vi nginx.conf
CODE:


user  www www;
worker_processes 10;
pid /var/run/nginx.pid;
# [ debug | info | notice | warn | error | crit ]
error_log  /dev/null;
#error_log /data/logs/nginxerror.log;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
       use epoll;
       #maxclient = worker_processes * worker_connections / cpu_number
       worker_connections 51200;
}
http
{
       include       /usr/local/nginx/conf/mime.types;
       default_type  application/octet-stream;
       #charset  gb2312;
       charset gbk;
       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  /data/www/logs/access.log  main;
       access_log  /dev/null;
       #General Options
       server_names_hash_bucket_size 128;
       client_header_buffer_size 32k;
       large_client_header_buffers 4 32k;
       ignore_invalid_headers   on;
       recursive_error_pages    on;
       server_name_in_redirect off;
      
       sendfile                 on;
       #timeouts
       keepalive_timeout 60;
      
       #TCP Options
       tcp_nopush  on;
       tcp_nodelay on;
       #fastcgi options
       fastcgi_connect_timeout 300;
       fastcgi_send_timeout 300;
       fastcgi_read_timeout 300;
      
       fastcgi_buffer_size 128k;
       fastcgi_buffers 4 128k;
       fastcgi_busy_buffers_size 128k;
       fastcgi_temp_file_write_size 128k;
       fastcgi_intercept_errors on;
       ssi on;
       ssi_silent_errors on;
       ssi_types text/shtml;
       #size limits
       client_max_body_size       50m;
       client_body_buffer_size    256k;
       #gzip  compression
       gzip on;
       gzip_min_length  0;
       gzip_buffers     16 8k;
       gzip_http_version 1.0;
       gzip_comp_level 9;
       gzip_types       text/plain text/css image/x-icon image/png;
       gzip_vary on;
       #temp files
       proxy_temp_path            /dev/shm/proxy_temp;
       fastcgi_temp_path          /dev/shm/fastcgi_temp;
       client_body_temp_path      /dev/shm/client_body_temp;
       #client_body_temp_path  /usr/local/nginx/client_body_temp 1 2;
       #proxy_temp_path        /usr/local/nginx/proxy_temp 1 2;
       #fastcgi_temp_path      /usr/local/nginx/fastcgi_temp 1 2;
      
       #upstream
       upstream  spawn {
       # ip_hash;
        server   127.0.0.1:9000 max_fails=0 fail_timeout=30s;
        server   127.0.0.1:9001 max_fails=0 fail_timeout=30s;
       }
       # The following includes are specified for virtual hosts
        #www.linuxtone.org
        include          /usr/local/nginx/conf/vhosts/www.linuxtone.org.conf;
}
#mkdir vhosts
#vi vhosts/www.linuxtone.org.conf
CODE:


server
       {
               listen       80;
               server_name  www.linuxtone.org .linuxtone.org;
               index index.html index.htm index.php;
               root  /data/www/wwwroot/linuxtone;
               error_page 404 http://www.linuxtone.org;
               #rewrite ^/bbs/(.*) http://bbs.linuxtone.org/$1;
               location ~ .*\.php?$
               {
                       fastcgi_pass spawn;
                       include /usr/local/nginx/conf/spawn_php5.conf;
                       fastcgi_index  index.php;
               }
               location ~* \.(js|css|jpg|jpeg|gif|png)$ {
               if (-f $request_filename) {
                  access_log   off;
                  expires      1d;
                  break;
                  }
                }
       }
#vi /usr/local/nginx/conf/spawn_php5.conf
CODE:

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param REDIRECT_STATUS 200;
3.2 配置spawn-fcgi启动脚本
#mkdir /usr/local/php/sbin
# vi /usr/local/php/sbin/spawn-fcgi
CODE:

#! /bin/sh

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="spawn-fcgi daemon"
NAME=spawn-fcgi
DAEMON=/usr/local/bin/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

d_start() {
$DAEMON -a 127.0.0.1 -p 9000 -C 128 -u www -g www -f /usr/local/php/bin/php-cgi > /dev/null 2>&1
$DAEMON -a 127.0.0.1 -p 9001 -C 128 -u www -g www -f /usr/local/php/bin/php-cgi > /dev/null 2>&1 || echo -n " already running"
}

d_stop() {
/usr/bin/killall -9 php-cgi > /dev/null 2>&1 || echo -n " not running"
}

case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
exit 3
;;
esac

exit 0
#chmod 755 /usr/local/php/sbin/spawn-fcgi
四、启动WEB服务
4.1.启动spawn-fcgi
#/usr/local/php/sbin/spawn-fcgi start
4.2.启动nginx
4.2.1检查nginx配置:
# /usr/local/nginx/sbin/nginx –t     //返回如下信息说明配置正确
CODE:

the configuration file /usr/local/nginx//conf/nginx.conf syntax is ok
configuration file /usr/local/nginx//conf/nginx.conf test is successful
#/usr/local/nginx/sbin/nginx    //启动nginx
4.3.加入开机启动
#vi /etc/rc.local
在最后加入:
CODE:


ulimit -SHn 51200
/usr/local/nginx/sbin/nginx
/usr/local/php/sbin/spawn-fcgi start
五、测试
#mkdir /data/www/wwwroot/linuxtone
#vi phpinfo.php

论坛徽章:
0
30 [报告]
发表于 2010-05-04 22:36 |只看该作者
我用FreeBSD7.2经常出现502。不知道为什么。请加我53252734
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP