PHP-FPM 不处理 php 请求

PHP-FPM 不处理 php 请求

我有一个奇怪的情况,我已经通过 aptitude 安装了 lighttpd 和 php5-fpm

我已经创建了一个 vhost 和 fpm 池。

这是 main.conf(全局 FPM)

[global]

        pid = /var/run/php-fpm.pid

        error_log = /home/lighttpd/log/php-fpm.log

        log_level = error

        emergency_restart_threshold = 5

        emergency_restart_interval = 2

        process_control_timeout = 2

        daemonize = yes

        include=/home/lighttpd/vhosts/*/conf/php-fpm.conf

这是虚拟主机的池

[website.com]
    listen                 = 127.0.0.1:9000
    listen.backlog         = -1

    user  = website.com
    group = website.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


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

    chroot = /home/lighttpd/vhosts/website.com/web
    ; Chdir to this directory at the start. This value must be an absolute path.
    ; Default Value: current directory or / when chroot
    ;chdir = /

    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 配置是:

## Moduli da caricare
server.modules                 = (
    "mod_alias",
    "mod_compress",
    "mod_rewrite",
    "mod_redirect",
    "mod_accesslog"
)

## Document root
server.document-root           = "/home/lighttpd/vhosts/"

## File temporanei.
server.upload-dirs             = ("/home/lighttpd/tmp")

## LOG
server.errorlog                = "/home/lighttpd/log/error.log"
accesslog.filename             = "/home/lighttpd/log/access.log"


## File ricercati quando viene richiesta una directory
index-file.names               = (
    "index.php",
    "index.html",
    "index.htm",
    "default.htm"
)


## Negare l'accesso al codice sorgente di questi file
static-file.exclude-extensions = (
    ".php",
    ".pl",
    ".fcgi",
    ".conf"
)

server.pid-file                = "/var/run/lighttpd.pid"

dir-listing.encoding           = "utf-8"
server.dir-listing             = "disable"

server.username                = "lighttpd"
server.groupname               = "lighttpd"


## Compressione dei contenuti
compress.cache-dir             = "/home/lighttpd/cache/"
compress.filetype              = (
    "text/plain",
    "text/html",
    "application/x-javascript",
    "text/css"
)

## Mapping dei mimetype
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

#Virtual Hosts
include "/home/lighttpd/vhosts/vhosts.conf"

并且虚拟主机是:

## WEBSITE.COM
$HTTP["host"] =~ "(^|.)website\.com$" {
    server.document-root = "/home/lighttpd/vhosts/website.com/web"
    server.errorlog      = "/home/lighttpd/vhosts/website.com/log/error.log"
    accesslog.filename   = "/home/lighttpd/vhosts/website.com/log/access.log"


    fastcgi.server = ( ".php" =>
                          ( "localhost" =>
                            (
                              "host" => "127.0.0.1",
                              "port" => "9000"
                            )
                          )
)


}

如果我访问www.website.com/page.html它效果很好。

如果我访问www.website.com/page.php我总是得到404 错误

我真的不知道该如何修复它。我还检查了进程列表,所有进程都启动正常:

lighttpd   974  0.0  0.0  88812  2136 ?        S    02:13   0:00 /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
root       998  0.0  0.1 127268  4316 ?        Ss   02:13   0:00 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf
1004       999  0.0  0.1 127812  4628 ?        S    02:13   0:00 /usr/sbin/php5-fpm --fpm-config /etc/php5/fpm/main.conf

网络状态监测确认它:

tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      998/php5-fpm   

有人能帮帮我吗?我不明白为什么 PHP 页面没有被处理... 我也检查了 .log,但没有看到错误。

更新

我尝试了chroot /home/lighttpd/vhosts/website.com/chdir /web针对 http 文档),但没有任何效果。我的 php-fpm.conf(池)位于/home/lighttpd/vhosts/website.com/conf/php-fpm.conf

答案1

尝试摆脱chroot池配置,我认为 Web 服务器正在将完整的文件路径传递给 FastCGI 服务器,并且(当然)它将无法找到该文件。

相关内容