ZBlogger技术交流中心

 找回密码
 注册

QQ登录

只需一步,快速开始

Z-BlogPHP 最新开发动态 下载最新版:Z-BlogPHP 1.5 Zero Wordpress转换 - Emlog转换 - 找回密码

Z-BlogASP 最新开发动态 下载最新版:Z-Blog 2.2 Prism Build 140101 转换到Z-BlogPHP - 1.8升级指南 - 找回密码

DBS官方主机/域名/VPS 推荐:Z-BlogPHP主机-Z-BlogASP主机 联系值班客服(每天9:00-21:30)

搜索
【聚划算】宅男最新神器!你懂的!环球外贸论坛
查看: 2947|回复: 0

CentOS+Nginx+PHP+Mysql环境配置(三)

[复制链接]
发表于 2014-8-21 04:52:55 | 显示全部楼层 |阅读模式
[创建www用户和组]
  1. # /usr/sbin/groupadd www -g 48
  2. ↑ 创建www用户组并指定组ID为48
  3. # /usr/sbin/useradd -u 48 -g www www
  4. ↑ 创建www用户到www用户组中
  5. # mkdir -p /wwwroot
  6. ↑ 在根目录中创建wwwroot网站目录
  7. # chmod +w /wwwroot
  8. ↑ 给wwwroot目录增加可写权限
  9. # chown -R www:www /wwwroot
  10. ↑ 使wwwroot目录所属用户组为www,所属用户为www
复制代码

[创建php-fpm配置文件] (注意php5.3.6 已经不使用xml文件配置了)


  1.     php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi
  2.     # rm -f /usr/local/webserver/php/etc/php-fpm.conf
  3.     ↑ 删除原有php-fpm.conf文件
  4.     # vi /usr/local/webserver/php/etc/php-fpm.conf
  5.     ↑ 建立新的php-fpm.conf文件并启动vi编辑器编辑该文件
  6.     输入以下内容(请注意以下内容中"↑"标志后的内容不能出现在实际文件中):

  7.     <?xml version="1.0" ?>
  8.     <configuration>

  9.     All relative paths in this config are relative to php's install prefix

  10.     <section name="global_options">

  11.     Pid file
  12.     <value name="pid_file">/usr/local/webserver/php/logs/php-fpm.pid</value>

  13.     Error log file
  14.     <value name="error_log">/usr/local/webserver/php/logs/php-fpm.log</value>

  15.     Log level
  16.     <value name="log_level">notice</value>

  17.     When this amount of php processes exited with SIGSEGV or SIGBUS ...
  18.     <value name="emergency_restart_threshold">10</value>

  19.     ... in a less than this interval of time, a graceful restart will be initiated.
  20.     Useful to work around accidental curruptions in accelerator's shared memory.
  21.     <value name="emergency_restart_interval">1m</value>

  22.     Time limit on waiting child's reaction on signals from master
  23.     <value name="process_control_timeout">5s</value>

  24.     Set to 'no' to debug fpm
  25.     <value name="daemonize">yes</value>

  26.     </section>

  27.     <workers>

  28.     <section name="pool">

  29.     Name of pool. Used in logs and stats.
  30.     <value name="name">default</value>

  31.     Address to accept fastcgi requests on.
  32.     Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
  33.     <value name="listen_address">127.0.0.1:9000</value>

  34.     <value name="listen_options">

  35.     Set listen(2) backlog
  36.     <value name="backlog">-1</value>

  37.     Set permissions for unix socket, if one used.
  38.     In Linux read/write permissions must be set in order to allow connections from web server.
  39.     Many BSD-derrived systems allow connections regardless of permissions.
  40.     <value name="owner"></value>
  41.     <value name="group"></value>
  42.     <value name="mode">0666</value>
  43.     </value>

  44.     Additional php.ini defines, specific to this pool of workers.
  45.     <value name="php_defines">
  46.     <value name="sendmail_path">/usr/sbin/sendmail -t -i</value>
  47.     <value name="display_errors">0</value>
  48.     ↑ 如果安装 Nginx + PHP 用于程序调试,则此处应设置为"1"以显示PHP错误信息,设置为"0" Nginx 会报状态为500的空白错误页
  49.     </value>

  50.     Unix user of processes
  51.     <value name="user">www</value>

  52.     Unix group of processes
  53.     <value name="group">www</value>

  54.     Process manager settings
  55.     <value name="pm">

  56.     Sets style of controling worker process count.
  57.     Valid values are 'static' and 'apache-like'
  58.     <value name="style">static</value>

  59.     Sets the limit on the number of simultaneous requests that will be served.
  60.     Equivalent to Apache MaxClients directive.
  61.     Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
  62.     Used with any pm_style.
  63.     <value name="max_children">64</value>
  64.     ↑ 进程数为64,如果服务器内存大于3GB,可以只开启128-200个进程

  65.     Settings group for 'apache-like' pm style
  66.     <value name="apache_like">

  67.     Sets the number of server processes created on startup.
  68.     Used only when 'apache-like' pm_style is selected
  69.     <value name="StartServers">20</value>

  70.     Sets the desired minimum number of idle server processes.
  71.     Used only when 'apache-like' pm_style is selected
  72.     <value name="MinSpareServers">5</value>

  73.     Sets the desired maximum number of idle server processes.
  74.     Used only when 'apache-like' pm_style is selected
  75.     <value name="MaxSpareServers">35</value>

  76.     </value>

  77.     </value>

  78.     The timeout (in seconds) for serving a single request after which the worker process will be terminated
  79.     Should be used when 'max_execution_time' ini option does not stop script execution for some reason
  80.     '0s' means 'off'
  81.     <value name="request_terminate_timeout">0s</value>

  82.     The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
  83.     '0s' means 'off'
  84.     <value name="request_slowlog_timeout">0s</value>

  85.     The log file for slow requests
  86.     <value name="slowlog">logs/slow.log</value>

  87.     Set open file desc rlimit
  88.     <value name="rlimit_files">51200</value>

  89.     Set max core size rlimit
  90.     <value name="rlimit_core">0</value>

  91.     Chroot to this directory at the start, absolute path
  92.     <value name="chroot"></value>

  93.     Chdir to this directory at the start, absolute path
  94.     <value name="chdir"></value>

  95.     Redirect workers' stdout and stderr into main error log.
  96.     If not set, they will be redirected to /dev/null, according to FastCGI specs
  97.     <value name="catch_workers_output">yes</value>

  98.     How much requests each process should execute before respawn.
  99.     Useful to work around memory leaks in 3rd party libraries.
  100.     For endless request processing please specify 0
  101.     Equivalent to PHP_FCGI_MAX_REQUESTS
  102.     <value name="max_requests">10240</value>

  103.     Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
  104.     Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)
  105.     Makes sense only with AF_INET listening socket.
  106.     <value name="allowed_clients">127.0.0.1</value>

  107.     Pass environment variables like LD_LIBRARY_PATH
  108.     All $VARIABLEs are taken from current environment
  109.     <value name="environment">
  110.     <value name="HOSTNAME">$HOSTNAME</value>
  111.     <value name="PATH">/usr/local/bin:/usr/bin:/bin</value>
  112.     <value name="TMP">/tmp</value>
  113.     <value name="TMPDIR">/tmp</value>
  114.     <value name="TEMP">/tmp</value>
  115.     <value name="OSTYPE">$OSTYPE</value>
  116.     <value name="MACHTYPE">$MACHTYPE</value>
  117.     <value name="MALLOC_CHECK_">2</value>
  118.     </value>

  119.     </section>

  120.     </workers>

  121.     </configuration>
复制代码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|ZBlogger技术交流中心 ( 鄂ICP备11007414号 鄂公网安备 42060602000101号

GMT+8, 2017-5-28 10:47 , Processed in 0.231342 second(s), 8 queries , APCu On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表