PHP5-FPM 和 MYSQL

发布于 2024-11-04 17:34:39 字数 1638 浏览 5 评论 0原文

我正在使用 lighttpd 和 pfp-fpm。 一切正常,但如果我在 php 脚本上调用 mysql_connect() ,我会得到一个空页面。 就像“被拒绝的操作”一样。

这是我的 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

这是我的lighttpd vhost:

$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"
                                )
                        )
        )

}

出了什么问题?如果我不使用 mysql,我可以正确看到 php 脚本的结果。

I'm using lighttpd and pfp-fpm.
All work correctly, but if I call a mysql_connect() on my php scripts I get an empty page.
Like a "denied operation".

This is my php-fpm.conf pool

[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:

$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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我一向站在原地 2024-11-11 17:34:39

打开错误显示并发布这些错误会很有帮助,但由于您可以使用 mysql 而无需 chrooting php,我猜您会收到一些连接错误,因为 php 尝试使用套接字连接到本地主机上的 mysql(使用 - 编译的 php) -with-mysql-sock=/var/mysql.sock),并且很可能此套接字位于您的 chroot 环境之外。

您可以尝试:

  • 重新编译 php 以不使用套接字,
  • 在 chroot 路径中创建到套接字的硬链接
  • 使用某些内部 IP(如 10.0.0.1,192.168.0.1)而不是环回

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.

You can try:

  • Recompiling php to not use socket
  • creating hard link to socket in your chrooted path
  • using some internal ip (like 10.0.0.1,192.168.0.1) instead of loopback
青衫负雪 2024-11-11 17:34:39

在我看来,所有问题都是因为用户和组是 example.com
我猜该用户无权执行请求的任务

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文