You are not logged in.

#1 2014-03-15 12:27:03

hp4
Member
Registered: 2014-03-15
Posts: 7

[solved] recent apache 2.4 + php-fpm upgrade not working

after the recent upgrade

from apache 2.2 with mod-php

to apache 2.4 with php-fpm

my owncloud website can not be accessed. The reason is that php-fpm does not provide a correct CGI-environment for php as can be seen with a little test file, i.e. at least the variable $_SERVER['SCRIPT_NAME'] is not set correctly (https://bugs.php.net/bug.php?id=65641). Up to now there has been no source correction in the past 6 months. And I don't know whether the patch mentioned in the bug report is correct / has been tested / how to include it in the archlinux distribution......

I don't see a way to correct this in the configuration files. So what should be the strategy in archlinux ?

- apache 2.4 with php-fpm ??  does not work...
- apache 2.4 with disabled multithreading and use of old mod-php ??  To me it seems not reasonable.....
- fallback to apache 2.2 and mod-php  ??
- use of other webserver-solutions??  may also suffer from bugs (see https://bbs.archlinux.org/viewtopic.php?id=178514)

Last edited by hp4 (2014-03-16 19:20:56)

Offline

#2 2014-03-15 12:31:22

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

Have you searched the forum?

Offline

#3 2014-03-15 13:07:57

hp4
Member
Registered: 2014-03-15
Posts: 7

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

I've done a lot of searching in google and forums for archlinux / archlinuxarm / php / owncloud, but found no viable solution. The archlinux wiki only explains how to disable multithreading in apache 2.4 and stay with the old mod-php-solution. (I'm not an apache expert but to me this doesn't seem to be reasonable since multithreading normally is the better/more advanced technology.)

It's clearly a bug in the apache 2.4 + php-fpm package as can be seen by dumping the CGI-environment with a little php-file: obviously the value for 'SCRIPT_NAME' is not correct and will cause every php-based website to fail which relies on this value (like owncloud). The variable PHP_SELF also has a strange value with duplicated path-info, but owncloud seems not to use it. The values are cleary not compliant with the CGI-spec.

1) owncloud runs fine with apache 2.2 and finds itself in the environment

REQUEST_URI /index.php/apps/files
SCRIPT_NAME /index.php
PATH_INFO /apps/files
PATH_TRANSLATED /srv/www/htdocs/apps/files
PHP_SELF /index.php/apps/files

2) owncloud does not run with apache 2.4 maybe due to a different environment from mod-fpm

REQUEST_URI /index.php/apps/files
SCRIPT_NAME /index.php/apps/files
PATH_INFO /apps/files
ORIG_SCRIPT_FILENAME /srv/http/webspace/owncloud/index.php/apps/files
PATH_TRANSLATED /srv/http/webspace/owncloud/apps/files
PHP_SELF /index.php/apps/files/apps/files

Offline

#4 2014-03-15 13:27:41

Pajaro
Member
Registered: 2004-04-21
Posts: 884

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

bug and missconfiguration are totally different things. For respect on the works others do, say that you cant make it work. I say this because in the link you pass for "nginx bug" looks like missconfiguration.

Have you tried to remap the SCRIPT_NAME variables? google has lots of posts on this.

Offline

#5 2014-03-15 13:31:35

progandy
Member
Registered: 2012-05-17
Posts: 5,200

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

Works for me:

uri:
http://localhost/info.php/path/info.ext?query=string
content of info.php: 
<?php phpinfo(); ?>
result:
PHP Version 5.5.10
...
Server API 	FPM/FastCGI 
...
_SERVER["SERVER_SOFTWARE"]	Apache/2.4.7 (Unix)
...
_SERVER["REQUEST_METHOD"]	GET
_SERVER["QUERY_STRING"]	query=string
_SERVER["REQUEST_URI"]	/info.php/path/info.ext?query=string
_SERVER["SCRIPT_NAME"]	/info.php
_SERVER["PATH_INFO"]	/path/info.ext
_SERVER["PATH_TRANSLATED"]	/srv/http/path/info.ext
_SERVER["PHP_SELF"]	/info.php/path/info.ext
...

configuration with mod_proxy_handler 0.2 just like in the wiki. (cgi.fix_pathinfo=1 in php.ini)
Edit: Here is the wiki section. It is nearly a step-by-step list of changes.

- apache 2.4 with disabled multithreading and use of old mod-php ??  To me it seems not reasonable.....

if you change mpm_event to mpm_prefork, then you restore the same configuration as apache 2.2. mpm_event was not stable yet in 2.2, so it hasn't been the default setting. I'd prefer 2.4 with prefork over 2.2, but php-fpm should be better if properly configured.

Last edited by progandy (2014-03-15 13:56:40)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#6 2014-03-15 13:47:53

phanisvara
Member
From: west bengal, india
Registered: 2012-07-08
Posts: 74

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

i'm not sure what your (OP's) problems are exactly; i've never used owncloud, so this may be different from my configuration.

i also didn't find easy-to-follow instructions on wiki, forum, or mailing list, but what i found, together with my error messages after the apache upgrade, enabled me to get things working again.

for one, php-fpm needs to be started separately from apache (httpd) service. and it needs to be configured, at least in my setup, to listen on 127.0.0.1:9000 instead of the default linux socket (/etc/php/php-fpm.conf).

then, each of my virtual host configurations needs a line telling php-fpm where to look for .php scripts, like the following:

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/home/phani/webapps/phani/$1

before the closing </VirtualHost> tag.

(if you're not using virtual hosts, this would go as the last line into httpd.conf.)

as i said, i don't know exactly what your problems are, but the above changes enabled me to use my apache setup again.

Last edited by phanisvara (2014-03-15 13:55:42)

Offline

#7 2014-03-15 15:34:42

hp4
Member
Registered: 2014-03-15
Posts: 7

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

@Pajaro : sorry, you are right. probably it's a configuration problem. But it's a bit frustrating, if you do a normal pacman system update and after that your webserver doesn't run and you spend days with searching the web for a new working configuration...... and yes, I set the SCRIPT_NAME to  a fixed value in ownclouds index.php and it works!

@progandy: apache tells me that it can't find mod_proxy_handler. pacman tells me that it doesn't know mod_proxy_handler. My platform is based on archlinuxarm. Can you give me some hint how to install mod_proxy_handler in this environment ( I would prefer a standard installation via pacman, I'm not very experienced with building packages from source...)

@phanisvara : I've done all the configuration changes you've described. So my hope is the missing mod_proxy_handler mentioned by progandy. The problem with owncloud still persists after changing the configuration according to your suggestions. ( when I modify the owncloud-sources by setting the environment fixed to the correct values manually, it will deliver the correct webpage, otherwise images, style-sheets, and other ressources can't be loaded because of wrong generated URLs, derived from wrong environment variables. In this case the webpage is only fragmentary delivered). So I suppose that you will run into the same problems when loading webpages with complex PHP-handling based on paths and script-names in the URL. Btw.: does your system have the mod_proxy_handler?

Offline

#8 2014-03-15 15:47:02

hp4
Member
Registered: 2014-03-15
Posts: 7

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

@progandy:

In the wiki you've send me I found a link to mod_proxy_handler:

https://aur.archlinux.org/packages/mod_proxy_handler/

with the commentary
-------------------------------------
This package is brilliant! I could not get owncloud running on apache 2.4 with php-fpm and ProxyPassMatch directives. After installing this package and performing the instructions, it is now working again.
-------------------------------------

So this is probably the solution, but my questions are:

- how can I install that via pacman ? pacman tells me that it only knows mod-fpm but not mod_proxy_handler.
- why isn't package mod_proxy_handler bundled with package mod-fpm if that's essential for a working configuration ? And why are the configuration changes in httpd.conf not provided as separate conf-files to be included?

Offline

#9 2014-03-15 17:24:30

progandy
Member
Registered: 2012-05-17
Posts: 5,200

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

- how can I install that via pacman ? pacman tells me that it only knows mod-fpm but not mod_proxy_handler.

https://wiki.archlinux.org/index.php/Ar … Repository

- why isn't package mod_proxy_handler bundled with package mod-fpm if that's essential for a working configuration ? And why are the configuration changes in httpd.conf not provided as separate conf-files to be included?

The package is just a temporary workaround until the patch for SetHandler support comes in the next apache release (probably 2.4.9 if no major bugs occur). You dont' need it for a functional setup, but ProxyPass is difficult to configure if php files and static files are in the same directory structure and a php-DirectoryIndex is wanted, too.
The conf-files are not provided since php-fpm is a universal package that works with all servers that support fastcgi (e.g. apache httpd, nginx, lighttpd) It is not difficult to copy those few lines from the wiki. If you want a separate file, then create one.

Edit: As of httpd 2.4.9 the SetHandler patch is not in the 2.4.x series yet. Maybe someone will merge it. On the other hand, the unix-socket patch has arrived. You can use it like this:

LoadModule proxy_handler_module modules/mod_proxy_handler.so
<Proxy "unix:/run/php-fpm/php-fpm.sock|fcgi://php-fpm.local/">
    # register php-fpm socket with fictional .local domain name.
    # we need at least one ProxySet directive in order to force the creation.
    # set something inconsequential like min=0 which is the default.
    ProxySet min=0
</Proxy>
<FilesMatch \.php$>
    # set the fictional domain (unix socket) as proxy for php files
    SetHandler "proxy:fcgi://php-fpm.local/"
</FilesMatch>
DirectoryIndex index.php index.html

Last edited by progandy (2014-03-18 11:27:50)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#10 2014-03-15 23:55:24

hp4
Member
Registered: 2014-03-15
Posts: 7

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

ok, it works, thanks for the help.

Offline

#11 2014-03-15 23:57:04

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

Please remember to mark your thread as [Solved] by editing your first post and prepending it to the title.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#12 2014-06-10 16:45:08

Nelio
Member
Registered: 2014-06-10
Posts: 1

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

Hello guys,

How did you make it works ? yikes

I'm tried hard and it look like there's nothing to do: it doesn't work at all.

I put apache in debug log level, he tell me he try:

[Tue Jun 10 18:23:54.465649 2014] [proxy:debug] [pid 27709:tid 140145274169088] proxy_util.c(2094): AH00942: FCGI: has acquired connection for (*)
[Tue Jun 10 18:23:54.465657 2014] [proxy:debug] [pid 27709:tid 140145274169088] proxy_util.c(2169): [client ::1:51697] AH00944: connecting fcgi://127.0.0.1:9000//srv/http/test.php to 127.0.0.1:9000
[Tue Jun 10 18:23:54.465744 2014] [proxy:debug] [pid 27709:tid 140145274169088] proxy_util.c(2304): [client ::1:51697] AH00947: connected //srv/http/test.php to 127.0.0.1:9000
[Tue Jun 10 18:23:54.466349 2014] [proxy:debug] [pid 27709:tid 140145274169088] proxy_util.c(2132): AH00943: FCGI: has released connection for (*)

But fpm with the same level of logs tell me he doesn't have any query....

Any idea how to fix it ?

Offline

#13 2014-06-24 16:37:11

hp4
Member
Registered: 2014-03-15
Posts: 7

Re: [solved] recent apache 2.4 + php-fpm upgrade not working

Hi Nelio,
sorry, I'm not an expert on this stuff, so I can't help. you. I can only tell: Archlinuxarm for Raspberry PI just updated Apache to 2.4.9 and PHP 5.5.13, but it still doesn't work out of the box!!!! You have to apply the above mentioned patches or workarounds, which is quite nasty for unexperienced users, who would prefer to rely on simple package installation.

BR
Hans-Peter

Offline

Board footer

Powered by FluxBB