简体   繁体   English

PHP5-FPM 和 MYSQL

[英]PHP5-FPM and MYSQL

I'm using lighttpd and pfp-fpm.我正在使用 lighttpd 和 pfp-fpm。 All work correctly, but if I call a mysql_connect() on my php scripts I get an empty page.一切正常,但如果我在 php 脚本上调用 mysql_connect(),我会得到一个空页面。 Like a "denied operation".就像“拒绝操作”一样。

This is my php-fpm.conf pool这是我的 php-fpm.conf 池

[example.com]
        listen             = 127.0.0.1:9001
        listen.backlog         = -1

        user  = example.com
        group = example.com

        pm                   = dynamic
        pm.max_requests      = 0
        pm.max_children      = 2
        pm.start_servers     = 1
        pm.min_spare_servers = 1
        pm.max_spare_servers = 1

        chroot = /home/vhosts/example.com/

        request_terminate_timeout = 2
        request_slowlog_timeout   = 1
        slowlog                   = /home/vhosts/example.com/log/php-slow.log

        catch_workers_output = yes

        env[HOSTNAME] = $HOSTNAME
        env[PATH] = /usr/local/bin:/usr/bin:/bin
        env[TMP] = /tmp
        env[TMPDIR] = /tmp
        env[TEMP] = /tmp

This is my lighttpd vhost:这是我的 lighttpd 虚拟主机:

$HTTP["host"] =~ "(^|.)example\.com$" {

        server.document-root = "/home/vhosts/example.com/web"
        server.errorlog      = "/home/vhosts/example.com/log/error.log"
        accesslog.filename   = "/home/vhosts/example.com/log/access.log"


        fastcgi.server = (
                        ".php" => (
                                "localhost" => (
                                        "docroot" => "/web",
                                        "host"    => "127.0.0.1",
                                        "port"    => "9001"
                                )
                        )
        )

}

What is wrong?怎么了? If I don't use mysql I can see the result of the php script correctly.如果我不使用 mysql 我可以正确看到 php 脚本的结果。

Turning on error display and posting those errors would be helpful, but since you can use mysql without chrooting php, I guess you are getting some connection error, since php tries to connect to mysql on localhost using socket ( php compiled with --with-mysql-sock=/var/mysql.sock ), and most likely this socket is outside your chrooted environment. Turning on error display and posting those errors would be helpful, but since you can use mysql without chrooting php, I guess you are getting some connection error, since php tries to connect to mysql on localhost using socket ( php compiled with --with-mysql-sock=/var/mysql.sock ),并且这个套接字很可能在您的 chrooted 环境之外。

You can try:你可以试试:

  • Recompiling php to not use socket重新编译 php 以不使用套接字
  • creating hard link to socket in your chrooted path在您的 chrooted 路径中创建到套接字的硬链接
  • using some internal ip (like 10.0.0.1,192.168.0.1) instead of loopback使用一些内部 ip(如 10.0.0.1,192.168.0.1)而不是环回

Seems to me all the problems are because of the user and group being example.com i guess that user doesnt have rights to perform the requested tasks在我看来,所有问题都是因为用户和组是 example.com 我猜用户无权执行请求的任务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM