免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4153 | 回复: 0
打印 上一主题 下一主题

nginx1.0.4+php5.3.5连接不到数据库的奇怪问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-09-12 21:40 |只看该作者 |倒序浏览
nginx1.0.4+php5.3.5连接不到数据库的奇怪问题



nginx1.0.4+php5.3.5
写了个程序
cat test.php
<?php
$a=mysql_connect('sql_ip','user','pass');
if ($a) {
echo "aaa";
} else {
echo "bbb";
}
用web访问显示bbb。php test.php得到aaa
用web访问页面链接不到数据库。使用php命令直接执行可以连接到

nginx错误信息是:
2011/09/06 19:50:32 [error] 12764#0: *15800 FastCGI sent in stderr: "PHP Warning:  mysql_connect(): Can't connect to MySQL server on 'sql_ip' (4) in /usr/local/website/test.php on line 2" while reading response header from upstream, client: client_ip, server: myurl.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "sql_ip"

php-fpm的错误信息是:
Sep 05 12:07:41.428903 [WARNING] [pool www] child 6629 exited on signal 15 (SIGTERM) after 497.676413 seconds from start
Sep 05 12:08:27.003124 [WARNING] [pool www] child 6630, script '/usr/local/website/webdata/resource/xy3737-10/xy5final/api/start.php' execution timed out (40.071277 sec), terminating

php-fpm的配置文件
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm_err.log
log_level = warning
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5s
[www]
listen = 127.0.0.1:9000
#listen = /tmp/php-cgi.sock
listen.backlog = 128
listen.owner = shared
listen.group = shared
user = shared
group = shared
pm = static
pm.max_children = 128
pm.start_servers = 32
pm.min_spare_servers = 20
pm.max_spare_servers = 45
pm.max_requests = 1024
pm.status_path = /php_status
request_terminate_timeout = 10s
request_slowlog_timeout = 2
slowlog = var/log/slow.log
rlimit_files = 65535
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

nginx的配置文件
user  shared;
worker_processes  4;
error_log  logs/error.log;
pid        logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
    worker_connections  65535;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    server_tokens off;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 32 32k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;
    access_log  logs/access.log ;
    sendfile        on;
    keepalive_timeout  65;
}
    server {
        listen       80 default;
        server_name  my_url;
        location / {
            root   /usr/local/website;
            index  index.php index.html;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~^/(php_status)$ {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
        allow all;
        }
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/website$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

=====================================================
最后我重启了php-fpm(注意是restart不是reload),就可以了。但过一段时间又不行了.求解
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP