[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openbsd-misc
Subject:    Re: httpd with multiple php-fpm pools in separate chroots
From:       Vadim Zhukov <persgray () gmail ! com>
Date:       2019-12-29 18:07:15
Message-ID: CAMy=nGGRHD=X9AVtb6r_U6aF0WE8wkvM-DwctsHHHy_4X-hQbQ () mail ! gmail ! com
[Download RAW message or body]

I have setup like below working for me, with base httpd and php-7.3
package. I have PHP web app installed into /var/www/webapp directory,
with 'web' subdirectory serving as HTTP root, and I only want to
handle request paths starting with '/api' here.

The /etc/httpd.conf:

server "my.server" {
        listen on * port 80
        location "/api/*" {
                root "/webapp/web"
                directory index "index.php"
                fastcgi socket "/run/php-webapp.sock"
        }
}

And the PHP FastCGI conf snip:

[webapp]
user = $pool
group = $pool
listen = /var/www/run/php-$pool.sock
listen.owner = www
listen.group = www
listen.mode = 0660

chroot = /var/www/$pool

вс, 29 дек. 2019 г. в 02:21, Nazar Zhuk <nazar@zhuk.online>:
>
> Hello,
>
> I am trying to run multiple PHP sites, each in it's own chroot:
> /var/www/site1, /var/www/site2, etc. Document roots are
> /var/www/siteX/htdocs.
>
> The issue is that fastcgi DOCUMENT_ROOT and SCRIPT_FILENAME generated by
> httpd are relative to httpd chroot and include /siteX. php-fpm can't
> find scripts.
>
> I tried to change DOCUMENT_ROOT and SCRIPT_FILENAME with "fastcgi
> param". This works for DOCUMENT_ROOT, but for SCRIPT_FILENAME, I need to
> pass the actual script name.
>
> Conceptually I need:
>
> fastcgi param SCRIPT_FILENAME "/htdocs/<request path>"
>
> Built-in macros like in "block return" and "request rewrite" don't work
> here.
>
> I can make this work with a single php file like this:
>
> server "site1" {
>          listen on * port 80
>          root "/site1/htdocs"
>          location "*.php" {
>                  fastcgi param DOCUMENT_ROOT "/htdocs"
>                  fastcgi param SCRIPT_FILENAME "/htdocs/test.php"
>                  fastcgi socket "/site1/run/php-fpm.sock"
>          }
> }
>
> This will serve http://site1/test.php which is located at
> /var/www/site1/htdocs/test.php
>
> Is there a solution or a workaround? Aside from running all php-fpm
> pools in /var/www chroot?
>
>
> Thanks.
>
> --
> Nazar
>


-- 
  WBR,
  Vadim Zhukov

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic