zhu2688
6/11/2014 - 12:59 PM

php环境 配置

php环境 配置

cp php-fpm.conf.default /etc/init.d/
chmod +x /etc/init.d/php-fpm
service php-fpm
chkconfig --add php-fpm
[PHP]
engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
output_buffering = 4096
;output_handler =
zlib.output_compression = Off
;zlib.output_compression_level = -1
;zlib.output_handler =
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
open_basedir = .:/conf/:/tmp:/opt
disable_functions = php_real_logo_guid,php_egg_logo_guid,php_ini_scanned_files,php_ini_loaded_file,readlink,linkinfo,symlink,link,exec,shell_exec,system,escapeshellcmd,escapeshellarg,passthru,proc_open,proc_close,proc_terminate,proc_get_status,proc_nice,getmyuid,getmygid,getmyinode,putenv,getopt,sys_getloadavg,getrusage,get_current_user,magic_quotes_runtime,set_magic_quotes_runtime,import_request_variables,debug_zval_dump,ini_alter,dl,pclose,popen,set_file_buffer,stream_get_transports,get_headers,mail,openlog,syslog,closelog,pfsockopen,posix_kill,virtual,mysql_pconnect,mb_send_mail,stream_wrapper_restore,mb_send_mail,show_source,chroot,chgrp,ini_restore
disable_classes =
;ignore_user_abort = On
;realpath_cache_size = 16k
;realpath_cache_ttl = 120
zend.enable_gc = On
;zend.multibyte = Off
;zend.script_encoding =
expose_php = On
max_execution_time = 60
max_input_time = 60
;max_input_nesting_level = 64
; max_input_vars = 1000
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = On
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
;report_zend_debug = 0
track_errors = Off
;xmlrpc_errors = 0
;xmlrpc_error_number = 0
html_errors = On
;docref_root = "/phpmanual/"
;docref_ext = .html
error_log =  "/opt/mynmp/logs/php/php_error_log"
;arg_separator.output = "&"
;arg_separator.input = ";&"
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
;enable_post_data_reading = Off
post_max_size = 50M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
;default_charset = "UTF-8"
;always_populate_raw_post_data = On
;include_path = ".:/php/includes"
doc_root =
user_dir =
extension_dir = "/opt/mynmp/lib/php/extensions"
enable_dl = Off
;cgi.force_redirect = 1
;cgi.nph = 1
;cgi.redirect_status_env =
;cgi.fix_pathinfo=1
;fastcgi.impersonate = 1
;fastcgi.logging = 0
;cgi.rfc2616_headers = 0
file_uploads = On
;upload_tmp_dir =
upload_max_filesize = 20M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
;from="john@doe.com"
;user_agent="PHP"
default_socket_timeout = 60
;auto_detect_line_endings = Off
zend_extension=/opt/mynmp/lib/php/extensions/no-debug-non-zts-20100525/opcache.so
opcache.memory_consumption=64
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.enable_file_override=1
opcache.fast_shutdown=1
opcache.enable_cli=1
opcache.force_restart_timeout=30
[CLI Server]
cli_server.color = On
[Date]
date.timezone = Asia/Shanghai
;date.default_latitude = 31.7667
;date.default_longitude = 35.2333
;date.sunrise_zenith = 90.583333
;date.sunset_zenith = 90.583333
[filter]
;filter.default = unsafe_raw
;filter.default_flags =
[iconv]
;iconv.input_encoding = ISO-8859-1
;iconv.internal_encoding = ISO-8859-1
;iconv.output_encoding = ISO-8859-1
[intl]
;intl.default_locale =
;intl.error_level = E_WARNING
[sqlite]
;sqlite.assoc_case = 0
[sqlite3]
;sqlite3.extension_dir =
[Pcre]
;pcre.backtrack_limit=100000
;pcre.recursion_limit=100000
[Pdo]
;pdo_odbc.connection_pooling=strict
;pdo_odbc.db2_instance_name
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
;phar.readonly = On
; http://php.net/phar.require-hash
;phar.require_hash = On
;phar.cache_list =
[mail function]
SMTP = localhost
smtp_port = 25
;sendmail_from = me@example.com
;sendmail_path =
;mail.force_extra_parameters =
mail.add_x_header = On
;mail.log = syslog
[SQL]
sql.safe_mode = Off
[ODBC]
;odbc.default_db    =  Not yet implemented
;odbc.default_user  =  Not yet implemented
;odbc.default_pw    =  Not yet implemented
;odbc.default_cursortype
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
;birdstep.max_links = -1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
;ibase.default_db =
;ibase.default_user =
;ibase.default_password =
;ibase.default_charset =
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
;mysqli.allow_local_infile = On
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
;mysqlnd.net_cmd_buffer_size = 2048
;mysqlnd.net_read_buffer_size = 32768
[OCI8]
;oci8.privileged_connect = Off
;oci8.max_persistent = -1
;oci8.persistent_timeout = -1
;oci8.ping_interval = 60
;oci8.connection_class =
;oci8.events = Off
;oci8.statement_cache_size = 20
;oci8.default_prefetch = 100
;oci8.old_oci_close_semantics = Off
[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[browscap]
;browscap = extra/browscap.ini
[Session]
session.save_handler = files
;session.save_path = "/tmp"
session.use_cookies = 1
;session.cookie_secure =
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
;session.entropy_length = 32
;session.entropy_file = /dev/urandom
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
;session.upload_progress.enabled = On
;session.upload_progress.cleanup = On
;session.upload_progress.prefix = "upload_progress_"
;session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS"
;session.upload_progress.freq =  "1%"
;session.upload_progress.min_freq = "1"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
;mssql.connect_timeout = 5
;mssql.timeout = 60
;mssql.textlimit = 4096
;mssql.textsize = 4096
;mssql.batchsize = 0
;mssql.datetimeconvert = On
mssql.secure_connection = Off
;mssql.max_procs = -1
;mssql.charset = "ISO-8859-1"
[Assertion]
;assert.active = On
;assert.warning = On
;assert.bail = Off
;assert.callback = 0
;assert.quiet_eval = 0
[mbstring]
;mbstring.language = Japanese
;mbstring.internal_encoding = EUC-JP
;mbstring.http_input = auto
;mbstring.http_output = SJIS
;mbstring.encoding_translation = Off
;mbstring.detect_order = auto
;mbstring.substitute_character = none;
;mbstring.func_overload = 0
;mbstring.strict_detection = Off
;mbstring.http_output_conv_mimetype=
[gd]
;gd.jpeg_ignore_warning = 0
[exif]
;exif.encode_unicode = ISO-8859-15
;exif.decode_unicode_motorola = UCS-2BE
;exif.decode_unicode_intel    = UCS-2LE
;exif.encode_jis =
;exif.decode_jis_motorola = JIS
;exif.decode_jis_intel    = JIS
[Tidy]
;tidy.default_config = /usr/local/lib/php/default.tcfg
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
;sysvshm.init_mem = 10000
[ldap]
ldap.max_links = -1
[mcrypt]
;mcrypt.algorithms_dir=
;mcrypt.modes_dir=
[dba]
;dba.default_handler=
[curl]
;curl.cainfo =
[Xdebug]
xdebug.profiler_enable=on 
xdebug.trace_output_dir="/opt/mynmp/logs/php/xdebug/" 
xdebug.profiler_output_dir="/opt/mynmp/logs/php/xdebug/" 
;include=etc/fpm.d/*.conf

[global]
pid = run/php-fpm.pid
error_log = /opt/mynmp/logs/php/php-fpm.log
;syslog.ident = php-fpm
;log_level = notice
;emergency_restart_threshold = 0
;emergency_restart_interval = 0
;process_control_timeout = 0
; process.max = 128
;daemonize = yes
 
;rlimit_files = 1024
;rlimit_core = 0
;events.mechanism = epoll
;systemd_interval = 10

[www]
;prefix = /path/to/pools/$pool
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = nobody
group = nobody

listen = 127.0.0.1:9000
;listen.backlog = 128

;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0660
 
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1
; process.priority = -19
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 4

;pm.process_idle_timeout = 10s;

;pm.max_requests = 500
;pm.status_path = /status
;ping.path = /ping
;ping.response = pong
;access.log = log/$pool.access.log
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
;slowlog = log/$pool.log.slow
;request_slowlog_timeout = 0
;request_terminate_timeout = 0
;rlimit_files = 1024
;rlimit_core = 0
;security.limit_extensions = .php .php3 .php4 .php5
 
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M
[opcache] 
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20121212/opcache.so
opcache.enable=1  #开关 默认打开
opcache.enable_cli=1 
opcache.validate_timestamps=1     # 默认1 如果置为1,则OPCACHE会自动检测文件的时间戳(检测周期为revalidate_freq),
opcache.memory_consumption=128    # 可用内存 单位M
opcache.revalidate_freq=60        # 多少秒检测下php文件是否变动
opcache.optimization_level=1 
opcache.error_log=/opt/logs/php/php_opcache.log #opcache 错误日志
opcache.log_verbosity_level =1 #将错误信息都导向 Web 服务器日志.默认的只有致命错误(level 0) 或者错误(level 1)才会被记录.
opcache.max_wasted_percentage=5   #“浪费”的内存达到此值对应的百分比,就会发起一个重启调度 
opcache.interned_strings_buffer=8 #interned string的内存大小
opcache.max_accelerated_files=4096 # 文件数量 
opcache.max_file_size=0           #被cache的文件的最大size,单位bytes。0表示不限
opcache.fast_shutdown=1           #打开时可使php在request shutdown时回收内
opcache.force_restart_timeout=30  #如果opcache处于非active状态,当N秒后opcache将自动重启
yum install pcre-devel或者安装pcre
1. install pcre
   tar xzf pcre-8.32.tar.gz
   cd pcre-8.32
   ./configure --prefix=/opt/mynmp
   make && make install

2. install nginx
   tar xzf nginx-1.6.1.tar.gz
   cd nginx-1.6.1
   1)注释debug
   ###  vi auto/cc/gcc
   ###  注释掉debug
   ###  最后几行中
   ###  删除 CFLAGS=”$CFLAGS -g” 一行
   可以减少nginx的体积

   2)修改header
   ### vi src/core/nginx.h
   #define NGINX_VERSION "1.xx"
   #define NGINX_VER "MYSERVER/" NGINX_VERSION
   #define NGINX_VAR "NGINX"
   #define NGX_OLDPID_EXT ".oldbin"

然后编译
./configure --prefix=/opt/mynmp --conf-path=/opt/mynmp/etc/ --with-pcre=/opt/build/pcre-8.32 --with-select_module --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/opt/build/openssl-1.0.0m --http-log-path=/opt/mynmp/logs/nginx --error-log-path=/opt/mynmp/logs/nginx/error.log --pid-path=/opt/mynmp/var/run/nginx.pid --with-zlib=/opt/build/zlib-1.2.8 --http-proxy-temp-path=/opt/mynmp/tmp/proxy_temp --http-fastcgi-temp-path=/opt/mynmp/tmp/fastcgi_temp --http-uwsgi-temp-path=/opt/mynmp/tmp/uwsgi_temp --http-scgi-temp-path=/opt/mynmp/tmp/scgi_temp --http-client-body-temp-path=/opt/mynmp/tmp/client_body_temp
make && make install
user  nobody;  
worker_processes  2;  
  
error_log  /opt/mynmp/logs/nginx/error.log;
#error_log  logs/error.log  notice;  
#error_log  logs/error.log  info;  
pid	/opt/mynmp/var/run/nginx.pid; 
events {
    use epoll;
    worker_connections  1024;  
}  
  
http {  
    include       mime.types;  
    default_type  application/octet-stream;  
    log_format  mylogs  '$remote_addr - $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for';
    access_log /opt/mynmp/logs/nginx/access.log mylogs;
    #access_log  logs/access.log  main;

    sendfile           on;
    server_tokens      off;
    tcp_nodelay        on;   
    tcp_nopush         on;  
    keepalive_timeout      65;  

    #gzip  on;
    server_names_hash_bucket_size 128;     #指定服务器名称哈希表的框大小  
  
    client_header_buffer_size 32k;           
    large_client_header_buffers 4 128k;     #以上两个是设定客户端请求的Header头缓冲区大小,对于cookie内容较大的请求,应增大改值。(400或414错误)  
    client_max_body_size 8m;                #允许客户端请求的最大单文件字节数  
    client_body_buffer_size 32k;            #缓冲区代理缓冲用户端请求的最大字节数,可以理解为保存到本地再传给用户  
   
    proxy_connect_timeout 600;              #nginx跟后端服务器连接超时时间(代理连接超时)  
    proxy_read_timeout    600;              #连接成功后,后端服务器响应时间(代理接收超时)  
    proxy_send_timeout    600;              #后端服务器数据回传时间(代理发送超时)  
    proxy_buffer_size     32k;              #设置代理服务器(nginx)保存用户头信息的缓冲区大小  
    proxy_buffers         4 32k;            #proxy_buffers缓冲区,网页平均在32k以下的话,这样设置  
    proxy_busy_buffers_size  64k;           #高负荷下缓冲大小(proxy_buffers*2)  
    proxy_temp_file_write_size  1024m;      #设定缓存文件夹大小,大于这个值,将从upstream服务器传递请求,而不缓冲到磁盘  
    proxy_ignore_client_abort on;           #不允许代理端主动关闭连接  
  
    gzip         on;  
    gzip_min_length      1k;  
    gzip_buffers         4 16k;  
    gzip_http_version     1.0;  
    gzip_proxied         any;  #前端是squid的情况下要加此参数,否则squid上不缓存gzip文件  
    gzip_comp_level     2;  
    gzip_types        text/plain application/x-javascript text/css application/xml;  
    gzip_vary on;  
     
    #注:proxy_temp_path和proxy_cache_path指定的路径必须在同一分区  
    proxy_temp_path   /cache/proxy_temp_path;  
    #设置Web缓存区名称为cache_one,内存缓存空间大小为200MB,1天没有被访问的内容自动清除,硬盘缓存空间大小为30GB。  
    proxy_cache_path  /cache/proxy_cache_path levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;  
  
    server {  
        listen       8012;  
        server_name  localhost.net;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;  
        location / {  
            root   /var/www/nginx;  
            index  index.html index.htm;  
        }  
        #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;  
        }  
  
        # 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$ {  
            proxy_pass  http://127.0.0.1:8011;  
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  
            #include        fastcgi_params;  
        }  
  
    #扩展名以.gif、.jpg、.css等结尾的静态文件缓存。  
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|mp3|mp4|flv|f4v|wmv|wma|mov)$  
  
        {  
            #如果后端的服务器返回502、504、执行超时等错误,自动将请求转发到upstream负载均衡池中的另一台服务器,实现故障转移。  
        proxy_next_upstream http_502 http_504 error timeout invalid_header;  
  
        proxy_cache cache_one;                   #进行缓存,使用Web缓存区cache_one  
        proxy_cache_valid 200 304 12h;           #对不同的HTTP状态码设置不同的缓存时间  
        proxy_cache_valid 301 302 1m;  
        proxy_cache_valid any 1m;  
        proxy_cache_key $host$uri$is_args$args;  #以域名、URI、参数组合成Web缓存的Key值,Nginx根据Key值哈希,存储缓存内容到二级缓存目录内  
        proxy_set_header  Host $host;  
        proxy_set_header  X-Real-IP  $remote_addr;  
        proxy_set_header X-Forwarded-For $remote_addr;  
        proxy_set_header Accept-Encoding "none";  #设定proxy_set_header Accept-Encoding '';   
                                                  #      (或是后台服务器关闭gzip),这样这台机器才  
                                                  #       不会缓存被压缩的文件,造成乱码  
        #proxy_set_header Accept-Encoding ""; #这个也可  
        proxy_ignore_headers "Cache-Control" "Expires"; #这段配置加上后,proxy_cache就能支持后台设定的expires。  
        #proxy_pass http://127.0.0.1:8011; #反向代理  
        root   /var/www/nginx;      
        expires  1h;  
        }  
    #设置只允许指定的IP或IP段才可以清除URL缓存。  
        location ~ /purge(/.*)  {  
            allow            127.0.0.1;  
            allow            192.168.0.0/255;  
            allow             all;  
            proxy_cache_purge cache_one $host$1$is_args$args;  
        }     
        # deny access to .htaccess files, if Apache's document root  
        # concurs with nginx's one  
        #  
        #location ~ /\.ht {  
        #    deny  all;  
        #}  
    }  
    #测试不同域名绑定同一端口  
    server {  
        listen       8012;  
        server_name  localhost.com;  
        location / {  
            root   /var/www/nginx2;  
            index  index.html index.htm;  
        }  
        error_page   500 502 503 504  /50x.html;  
        location = /50x.html {  
            root   html;  
        }  
        location ~ \.php$ {  
            proxy_pass  http://127.0.0.1:8011;  
        }  
    }  
      
    # 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;  
    #    server_name  localhost;  
  
  
    #    ssl                  on;  
    #    ssl_certificate      cert.pem;  
    #    ssl_certificate_key  cert.key;  
  
  
    #    ssl_session_timeout  5m;  
  
  
    #    ssl_protocols  SSLv2 SSLv3 TLSv1;  
    #    ssl_ciphers  HIGH:!aNULL:!MD5;  
    #    ssl_prefer_server_ciphers   on;  
  
  
    #    location / {  
    #        root   html;  
    #        index  index.html index.htm;  
    #    }  
    #}  
  
  
}  
#! /bin/sh

### BEGIN INIT INFO
# Provides:          php-fpm
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO

prefix=/usr/local
exec_prefix=${prefix}

php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=/tmp/php-fpm.pid


php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"


wait_for_pid () {
	try=0

	while test $try -lt 35 ; do

		case "$1" in
			'created')
			if [ -f "$2" ] ; then
				try=''
				break
			fi
			;;

			'removed')
			if [ ! -f "$2" ] ; then
				try=''
				break
			fi
			;;
		esac

		echo -n .
		try=`expr $try + 1`
		sleep 1

	done

}

case "$1" in
	start)
		echo -n "Starting php-fpm "

		$php_fpm_BIN --daemonize $php_opts

		if [ "$?" != 0 ] ; then
			echo " failed"
			exit 1
		fi

		wait_for_pid created $php_fpm_PID

		if [ -n "$try" ] ; then
			echo " failed"
			exit 1
		else
			echo " done"
		fi
	;;

	stop)
		echo -n "Gracefully shutting down php-fpm "

		if [ ! -r $php_fpm_PID ] ; then
			echo "warning, no pid file found - php-fpm is not running ?"
			exit 1
		fi

		kill -QUIT `cat $php_fpm_PID`

		wait_for_pid removed $php_fpm_PID

		if [ -n "$try" ] ; then
			echo " failed. Use force-quit"
			exit 1
		else
			echo " done"
		fi
	;;

	status)
		if [ ! -r $php_fpm_PID ] ; then
			echo "php-fpm is stopped"
			exit 0
		fi

		PID=`cat $php_fpm_PID`
		if ps -p $PID | grep -q $PID; then
			echo "php-fpm (pid $PID) is running..."
		else
			echo "php-fpm dead but pid file exists"
		fi
	;;

	force-quit)
		echo -n "Terminating php-fpm "

		if [ ! -r $php_fpm_PID ] ; then
			echo "warning, no pid file found - php-fpm is not running ?"
			exit 1
		fi

		kill -TERM `cat $php_fpm_PID`

		wait_for_pid removed $php_fpm_PID

		if [ -n "$try" ] ; then
			echo " failed"
			exit 1
		else
			echo " done"
		fi
	;;

	restart)
		$0 stop
		$0 start
	;;

	reload)

		echo -n "Reload service php-fpm "

		if [ ! -r $php_fpm_PID ] ; then
			echo "warning, no pid file found - php-fpm is not running ?"
			exit 1
		fi

		kill -USR2 `cat $php_fpm_PID`

		echo " done"
	;;

	*)
		echo "Usage: $0 {start|stop|force-quit|restart|reload|status}"
		exit 1
	;;

esac
1. install libxml
   tar xzf libxml2-2.7.1.tar.gz
   cd libxml2-2.7.1
   ./configure --prefix=/opt/mynmp
   make && make install
2. install freetype
   tar xzf freetype-2.5.3.tar.gz
   cd freetype-2.5.3
   ./configure --prefix=/opt/mynmp
   make && make install
3. install libjpeg
   tar xzf jpegsrc.v9a.tar.gz
   cd jpeg-9a
   ./configure --prefix=/opt/mynmp
   make && make install
4. install zlib
   tar xzf zlib-1.2.8.tar.gz
   cd zlib-1.2.8
   ./configure --prefix=/opt/mynmp
   make && make install
5. install libpng
   tar xzf libpng-1.6.12.tar.gz
   cd libpng-1.6.12
   export LDFLAGS="-L/opt/mynmp/lib"
   export CPPFLAGS="-I/opt/mynmp/include"
   ./configure --prefix=/opt/mynmp --with-zlib-prefix=/opt/mynmp
   make && make install
6. install libgd
   tar xzf gd-2.0.35.tar.gz
   cd gd-2.0.35
   ./configure --prefix=/opt/mynmp --with-freetype=/opt/mynmp/
   make && make install
7. install openssl
   tar xzf openssl-1.0.0m.tar.gz
   cd openssl-1.0.0m
   ./config --prefix=/opt/mynmp
   make && make install
   make clean 
   ./config shared --prefix=/opt/mynmp
   make && make install   
8. install curl
   tar xzf curl-7.37.1.tar.gz
   cd curl-7.37.1
   ./configure --prefix=/opt/mynmp --with-ssl=/opt/mynmp --with-zlib=/opt/mynmp
   make && make install
9. install php
   tar xzf php-5.4.31.tar.gz
   cd php-5.4.31
   vi /opt/mynmp/include/gd_io.h
   gdIOCtx结构中增加void *data;
   在27行 void (*gd_free) (struct gdIOCtx *);后面加一行
   void (*data);
   然后
   ./configure -prefix=/opt/mynmp --enable-ctype --enable-exif --enable-ftp --with-config-file-path=/opt/mynmp/etc --with-curl=/opt/mynmp --with-zlib=/opt/mynmp --with-zlib-dir=/opt/mynmp --with-jpeg-dir=/opt/mynmp --with-png-dir=/opt/mynmp --with-gd=/opt/mynmp --with-openssl=/opt/mynmp --with-openssl-dir=/opt/mynmp --with-mysql=/opt/mynmp --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --enable-mbstring --disable-debug --enable-sockets --disable-short-tags --with-libxml-dir=/opt/mynmp --with-freetype-dir=/opt/mynmp --enable-phar --enable-fpm
   make && make install
   
   cp php-5.4.31/php.ini-production /opt/mynmp/etc/php.ini
安装扩展
yum install m4
yum install autoconf
1.ZendOpcache
   tar xzf zendopcache-7.0.3.tgz
   cd zendopcache-7.0.3
   /opt/myrpm/bin/phpize
   ./configure --with-php-config=/opt/mynmp/bin/php-config
   make && make install
   
2.MemCached
   tar xzf libevent-2.0.21-stable.tar.gz
   cd libevent-2.0.21-stable
   ./configure --prefix=/opt/mynmp
   make && make install
   
   ##注意的是 让其他程序运行时能找到libevent库
   需要执行
   ln –s /usr/local/lib/libevent-2.0.so×  /usr/lib/libevent-2.0.so.×
   ##64位机器上还需要
   ln -s /usr/lib/libevent-2.0.so.× /usr/lib64/libevent-2.0.so.×

   tar xf memcached-1.4.20.tar.gz
   cd memcached-1.4.20
   ./configure --prefix=/opt/mynmp --with-libevent=/opt/mynmp
   make && make install
   
   tar xzf libmemcached-1.0.18.tar.tar
   cd libmemcached-1.0.18
   ./configure --prefix=/opt/mynmp
   make && make install
   
   tar xzf memcached-2.2.0.tgz 
   cd memcached-2.2.0
   /opt/mynmp/bin/phpize
   ./configure --with-php-config=/opt/mynmp/bin/php-config --with-zlib-dir=/opt/mynmp --with-libmemcached-dir=/opt/mynmp --disable-memcached-sasl
   make && make install
3.MemCache
  tar xzf memcache-3.0.8.tgz
  cd memcache-3.0.8
  path/to/phpize
  ./configure --with-php-config=/opt/mynmp/bin/php-config
  make && make install
4.Xdebug
   tar xzf xdebug-2.2.5.tgz
   cd xdebug-2.2.5
   /opt/mynmp/bin/phpize
   ./configure --with-php-config=/opt/mynmp/bin/php-config
   make && make install
   
5.Libmcrypt
  configure: error: mcrypt.h not found. Please reinstall libmcrypt.
  cd /usr/local/src/
  wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz
  tar xzf libmcrypt-2.5.8.tar.gz
  cd libmcrypt-2.5.8
  ./configure
  make && make install
6.SeasLog
  https://github.com/Neeke/SeasLog
  /path/to/phpize
  /configure --with-php-config=/path/to/php-config
  make && make install