php-fpm+nginx配置问题
| |
Posted in Unix/Linux/FreeBsd on 2009/01/09 / 引用(0)
原作者:http://hi.baidu.com/dugu2008/blog/item/0d9e9bf8e8c13b08d8f9fd14.html

一、启动php-fpm问题,查看日志文件,此日志文件是在php-fpm.conf中所定义的

1、Dec 01 11:01:07.339056 [WARNING] fpm_stdio_child_said(), line 158: child 25237 (pool default) said into stderr: "Dec 01 11:01:07.336368 [ERROR] fpm_unix_init_child(), line 168: setrlimit(RLIMIT_NOFILE) failed: Invalid argument (22)"

A:修改配置文件:

vi /etc/sysctl.conf

输入以下内容:

kernel.shmmax = 134217728

然后执行以下命令使配置生效:

sbin/sysctl –p

2、启动仍然失败,可是在日志中并没有详细记录出错信息,只有:

Dec 01 11:03:07.930313 [NOTICE] fpm_children_make(), line 352: child 25345 (pool default) started
Dec 01 11:03:07.934274 [NOTICE] fpm_children_make(), line 352: child 25346 (pool default) started
Dec 01 11:03:07.937472 [NOTICE] fpm_children_make(), line 352: child 25347 (pool default) started
Dec 01 11:03:07.942833 [NOTICE] fpm_children_make(), line 352: child 25348 (pool default) started
Dec 01 11:03:07.943068 [NOTICE] fpm_event_loop(), line 105: libevent: entering main loop

A:此问题的答案,google了好久都没找打解决办法,后来灵光一闪,上面说main loop,是不是什么地方不一致导致循环呢?

检查得到php-fpm.conf文件中的pid file被定义在

Pid file
/opt/php/logs/php-fpm.pid

而php-fpm启动文件(/opt/php/sbin/php-fpm)中定义的php_fpm_PID=/opt/php/logs/php-fpm.pid

修改php-fpm.conf配置文件中的位置与启动脚本一致,然后执行/opt/php/sbin/php-fpm start成功 ^_^

二、nginx部分

1、No input file specified 报错

A、在网上搜到的都是修改php.ini文件中的doc_root,将其注释掉,后来发现根本没用,摸索N久之后,终于发现解决办法:

fcgi.conf文件(有些直接使用nginx的fastcgi_params文件),其中要有如下一行:

fastcgi_param    SCRIPT_FILENAME      $document_root$fastcgi_script_name;

另外要注意虚拟主机的配置文件:

我以前的配置文件如下:

       location / {

           root   /webserver/web;
           index index.php index.html index.htm;

           if (-f $request_filename/index.html){
               rewrite (.*) $1/index.html break;
           }
           if (-f $request_filename/index.php){
               rewrite (.*) $1/index.php;
           }
           if (!-f $request_filename){
               rewrite (.*) /index.php;
           }
       }

       error_page 404    http://www.netbig.com/error/error404.htm;

       location ~ \.php$ {
           fastcgi_pass   unix:/var/run/fcgi/php-cgi.sock;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME /webserver/web$fastcgi_script_name;
           fastcgi_param PATH_INFO $fastcgi_script_name;

           include         fcgi.conf;
       }

修改成如下:

       root   /webserver/web;

       location / {
           index index.php index.html index.htm;

           if (-f $request_filename/index.html){
               rewrite (.*) $1/index.html break;
           }
           if (-f $request_filename/index.php){
               rewrite (.*) $1/index.php;
           }
           if (!-f $request_filename){
               rewrite (.*) /index.php;
           }
       }

       error_page 404    http://www.netbig.com/error/error404.htm;

       location ~ \.php$ {

           fastcgi_pass   unix:/var/run/fcgi/php-cgi.sock;
           fastcgi_index index.php;
           #fastcgi_param SCRIPT_FILENAME /webserver/web$fastcgi_script_name;
           #fastcgi_param PATH_INFO $fastcgi_script_name;
           include         fcgi.conf;
       }

改动的地方是将root部分从location /迁移出来,或者放到location ~ \.php$部分,这个是与spawn-fcgi不同的地方

并注释掉fastcgi_param
This entry comes from 本站原创 and has been read for 1716 times.It is tagged with , , , .
0 Responses
发表评论

昵称

网址

电邮

OpenID登入 高级选项 表情