[Ubuntu] Apache 2.4 + php 5.2.17 werkt niet

Pagina: 1
Acties:

Acties:
  • 0 Henk 'm!

  • bennierex
  • Registratie: April 2001
  • Laatst online: 13-10 10:59
Ik heb (virtueel) een machine draaien met Ubuntu server 12.04LTS als O/S. Het systeem draait een Apache 2.4.3 webserver met een 20-tal vhosts. De meeste van de sites in deze vhosts maken gebruik van php 5.3 of 5.4, maar een beperkt aantal heeft php 5.2 nodig.
De drie php versies draaien als fpm, ieder op een andere poort (9000 / 9001 / 9002). Alle sites die draaien op 5.3 of 5.4 werken zonder problemen, echter de sites op 5.2 krijg ik met geen mogelijkheid aan de praat. Met onderstaande config krijg ik een 404 ("The requested URL /info.php was not found on this server.") als ik bijv. http://tst.host/info.php opvraag uit de docroot. Het lijkt me iets met het doorgeven van het absolute pad. :?

In de eerste instantie dacht ik dat het lag aan de fpm, echter ook via cgi of cli lukt het me niet de scripts te laten parsen. Als ik een script handmatig uitvoer via de command-line met de cgi of cli binaries, dan is de output gewoon correct en lijkt alles in orde. Hieruit concludeer ik dat het ligt aan mijn configuratie van Apache.

Hieronder de vhost config:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<VirtualHost *:80>
  ServerName tst.host
  DocumentRoot "/path/to/docroot"

  HostnameLookups Off
  UseCanonicalName Off

  LogLevel debug
  ErrorLog "logs/tst_error.log"

  <IfModule mod_dir.c>
    DirectoryIndex index.html
  </IfModule>

  <LocationMatch ^(.*\.php)$>
    ProxyPass fcgi://127.0.0.1:9000/path/to/docroot connectiontimeout=3000 timeout=3000
    ProxyErrorOverride on
    Require all granted
  </LocationMatch>

  <Directory "/path/to/docroot">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>

  ExpiresActive On
  ExpiresByType image/gif A2592000
  ExpiresByType image/png A2592000
  ExpiresByType image/jpeg A2592000
  ExpiresByType image/x-icon A2592000
  ExpiresByType text/css A2592000
  ExpiresByType text/x-js A2592000

  SetOutputFilter DEFLATE
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/x-js

  FileETag none

</VirtualHost>


Het volgende werkt dus wel:
$ /usr/local/php-5.2.17/bin/php-cgi /path/to/docroot/info.php

OF
$ /usr/local/php-5.2.17/bin/php /path/to/docroot/info.php


Het werkt ook als ik de poort in de vhost config verander naar de poort van 5.3 (9001) of 5.4 (9002), echter is de php code van die site niet compatible...

Iemand enig idee waar het fout kan gaan?

Note: zowel Apache als PHP heb ik zelf gecompileerd.

Acties:
  • 0 Henk 'm!

  • uashy
  • Registratie: Mei 2002
  • Laatst online: 31-05 17:44
Om even te testen of het aan de koppeling met php ligt, werkt het wel als je een simpel html bestand opvraagt?

En misschien nog wel belangrijker, wat zie je voor verschillen tussen met vhosts die een andere php versie benaderen? Zijn er verschillen in de configuratie of misschien op filesystem niveau?

[ Voor 46% gewijzigd door uashy op 29-01-2013 17:27 ]


Acties:
  • 0 Henk 'm!

  • Hero of Time
  • Registratie: Oktober 2004
  • Laatst online: 18:46

Hero of Time

Moderator LNX

There is only one Legend

Check je logs ook, die verteld je wat er mis is.

Commandline FTW | Tweakt met mate


Acties:
  • 0 Henk 'm!

  • bennierex
  • Registratie: April 2001
  • Laatst online: 13-10 10:59
uashy schreef op dinsdag 29 januari 2013 @ 17:11:
Om even te testen of het aan de koppeling met php ligt, werkt het wel als je een simpel html bestand opvraagt?
Ja dat werkt zonder problemen.
En misschien nog wel belangrijker, wat zie je voor verschillen tussen met vhosts die een andere php versie benaderen? Zijn er verschillen in de configuratie of misschien op filesystem niveau?
Op het path en de servername na zijn deze 100% identiek.
Hero Of Time schreef op dinsdag 29 januari 2013 @ 22:28:
Check je logs ook, die verteld je wat er mis is.
Het bijbehorende error-log (debug):
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[Wed Jan 30 09:13:25.664862 2013] [ssl:debug] [pid 18397:tid 140232292742976] ssl_engine_pphrase.c(181): AH02199: SSL not enabled on vhost tst.host:80, skipping SSL setup
[Wed Jan 30 09:13:25.692190 2013] [proxy:debug] [pid 20454:tid 140232292742976] proxy_util.c(1657): AH00925: initializing worker fcgi://127.0.0.1:9000/path/to/docroot shared
[Wed Jan 30 09:13:25.692226 2013] [proxy:debug] [pid 20454:tid 140232292742976] proxy_util.c(1697): AH00927: initializing worker fcgi://127.0.0.1:9000/path/to/docroot local
[Wed Jan 30 09:13:25.692241 2013] [proxy:debug] [pid 20454:tid 140232292742976] proxy_util.c(1729): AH00930: initialized pool in child 20454 for (127.0.0.1) min=0 max=25 smax=25
[Wed Jan 30 09:13:25.692356 2013] [proxy:debug] [pid 20455:tid 140232292742976] proxy_util.c(1657): AH00925: initializing worker fcgi://127.0.0.1:9000/path/to/docroot shared
[Wed Jan 30 09:13:25.692389 2013] [proxy:debug] [pid 20455:tid 140232292742976] proxy_util.c(1697): AH00927: initializing worker fcgi://127.0.0.1:9000/path/to/docroot local
[Wed Jan 30 09:13:25.692400 2013] [proxy:debug] [pid 20455:tid 140232292742976] proxy_util.c(1729): AH00930: initialized pool in child 20455 for (127.0.0.1) min=0 max=25 smax=25
[Wed Jan 30 09:13:25.692574 2013] [proxy:debug] [pid 20456:tid 140232292742976] proxy_util.c(1657): AH00925: initializing worker fcgi://127.0.0.1:9000/path/to/docroot shared
[Wed Jan 30 09:13:25.692604 2013] [proxy:debug] [pid 20456:tid 140232292742976] proxy_util.c(1697): AH00927: initializing worker fcgi://127.0.0.1:9000/path/to/docroot local
[Wed Jan 30 09:13:25.692615 2013] [proxy:debug] [pid 20456:tid 140232292742976] proxy_util.c(1729): AH00930: initialized pool in child 20456 for (127.0.0.1) min=0 max=25 smax=25
[Wed Jan 30 09:13:27.082842 2013] [proxy:debug] [pid 20538:tid 140232292742976] proxy_util.c(1657): AH00925: initializing worker fcgi://127.0.0.1:9000/path/to/docroot shared
[Wed Jan 30 09:13:27.082898 2013] [proxy:debug] [pid 20538:tid 140232292742976] proxy_util.c(1697): AH00927: initializing worker fcgi://127.0.0.1:9000/path/to/docroot local
[Wed Jan 30 09:13:27.082909 2013] [proxy:debug] [pid 20538:tid 140232292742976] proxy_util.c(1729): AH00930: initialized pool in child 20538 for (127.0.0.1) min=0 max=25 smax=25
[Wed Jan 30 09:13:38.262660 2013] [authz_core:debug] [pid 20456:tid 140231999178496] mod_authz_core.c(802): [client 10.0.0.24:58629] AH01626: authorization result of Require all granted: granted
[Wed Jan 30 09:13:38.262698 2013] [authz_core:debug] [pid 20456:tid 140231999178496] mod_authz_core.c(802): [client 10.0.0.24:58629] AH01626: authorization result of <RequireAny>: granted
[Wed Jan 30 09:13:38.262714 2013] [proxy_fcgi:debug] [pid 20456:tid 140231999178496] mod_proxy_fcgi.c(120): [client 10.0.0.24:58629] AH01060: set r->filename to proxy:fcgi://127.0.0.1:9000/path/to/docroot/info.php
[Wed Jan 30 09:13:38.262733 2013] [proxy:debug] [pid 20456:tid 140231999178496] mod_proxy.c(1070): [client 10.0.0.24:58629] AH01143: Running scheme fcgi handler (attempt 0)
[Wed Jan 30 09:13:38.262740 2013] [proxy_fcgi:debug] [pid 20456:tid 140231999178496] mod_proxy_fcgi.c(944): [client 10.0.0.24:58629] AH01076: url: fcgi://127.0.0.1:9000/path/to/docroot/info.php proxyname: (null) proxyport: 0
[Wed Jan 30 09:13:38.262745 2013] [proxy_fcgi:debug] [pid 20456:tid 140231999178496] mod_proxy_fcgi.c(954): [client 10.0.0.24:58629] AH01078: serving URL //127.0.0.1:9000/path/to/docroot/info.php
[Wed Jan 30 09:13:38.262756 2013] [proxy:debug] [pid 20456:tid 140231999178496] proxy_util.c(1978): AH00942: FCGI: has acquired connection for (127.0.0.1)
[Wed Jan 30 09:13:38.262762 2013] [proxy:debug] [pid 20456:tid 140231999178496] proxy_util.c(2030): [client 10.0.0.24:58629] AH00944: connecting //127.0.0.1:9000/path/to/docroot/info.php to 127.0.0.1:9000
[Wed Jan 30 09:13:38.262809 2013] [proxy:debug] [pid 20456:tid 140231999178496] proxy_util.c(2152): [client 10.0.0.24:58629] AH00947: connected /path/to/docroot/info.php to 127.0.0.1:9000
[Wed Jan 30 09:13:38.267153 2013] [proxy:debug] [pid 20456:tid 140231999178496] proxy_util.c(1993): AH00943: FCGI: has released connection for (127.0.0.1)
[Wed Jan 30 09:13:45.910536 2013] [authz_core:debug] [pid 20455:tid 140232074712832] mod_authz_core.c(802): [client 10.0.0.24:58631] AH01626: authorization result of Require all granted: granted
[Wed Jan 30 09:13:45.910583 2013] [authz_core:debug] [pid 20455:tid 140232074712832] mod_authz_core.c(802): [client 10.0.0.24:58631] AH01626: authorization result of <RequireAny>: granted


En bij het gebruik van php 5.4:
code:
1
2
3
4
5
6
7
8
9
10
11
[Wed Jan 30 09:02:23.399050 2013] [authz_core:debug] [pid 18668:tid 140232185538304] mod_authz_core.c(802): [client 10.0.0.24:58431] AH01626: authorization result of Require all granted: granted, referer: http://tst.host/info.php
[Wed Jan 30 09:02:23.399070 2013] [authz_core:debug] [pid 18668:tid 140232185538304] mod_authz_core.c(802): [client 10.0.0.24:58431] AH01626: authorization result of <RequireAny>: granted, referer: http://tst.host/info.php
[Wed Jan 30 09:02:23.399083 2013] [proxy_fcgi:debug] [pid 18668:tid 140232185538304] mod_proxy_fcgi.c(120): [client 10.0.0.24:58431] AH01060: set r->filename to proxy:fcgi://127.0.0.1:9002/path/to/docroot/info.php, referer: http://tst.host/info.php
[Wed Jan 30 09:02:23.399095 2013] [proxy:debug] [pid 18668:tid 140232185538304] mod_proxy.c(1070): [client 10.0.0.24:58431] AH01143: Running scheme fcgi handler (attempt 0), referer: http://tst.host/info.php
[Wed Jan 30 09:02:23.399100 2013] [proxy_fcgi:debug] [pid 18668:tid 140232185538304] mod_proxy_fcgi.c(944): [client 10.0.0.24:58431] AH01076: url: fcgi://127.0.0.1:9002/path/to/docroot/info.php proxyname: (null) proxyport: 0, referer: http://tst.host/info.php
[Wed Jan 30 09:02:23.399105 2013] [proxy_fcgi:debug] [pid 18668:tid 140232185538304] mod_proxy_fcgi.c(954): [client 10.0.0.24:58431] AH01078: serving URL //127.0.0.1:9002/path/to/docroot/info.php, referer: http://tst.host/info.php
[Wed Jan 30 09:02:23.399109 2013] [proxy:debug] [pid 18668:tid 140232185538304] proxy_util.c(1978): AH00942: FCGI: has acquired connection for (127.0.0.1)
[Wed Jan 30 09:02:23.399114 2013] [proxy:debug] [pid 18668:tid 140232185538304] proxy_util.c(2030): [client 10.0.0.24:58431] AH00944: connecting //127.0.0.1:9002/path/to/docroot/info.php to 127.0.0.1:9002, referer: http://tst.host/info.php
[Wed Jan 30 09:02:23.399150 2013] [proxy:debug] [pid 18668:tid 140232185538304] proxy_util.c(2152): [client 10.0.0.24:58431] AH00947: connected /path/to/docroot/info.php to 127.0.0.1:9002, referer: http://tst.host/info.php
[Wed Jan 30 09:02:23.401286 2013] [proxy:debug] [pid 18668:tid 140232185538304] proxy_util.c(1993): AH00943: FCGI: has released connection for (127.0.0.1)
[Wed Jan 30 09:02:23.401400 2013] [deflate:debug] [pid 18668:tid 140232185538304] mod_deflate.c(763): [client 10.0.0.24:58431] AH01384: Zlib: Compressed 2146 to 2151 : URL /info.php, referer: http://tst.host/info.php


Rechten op de public folder en bestanden heb ik op 777 staan.

Edit:
Met loglevel op 'notice' in php, krijg ik geen enkele melding te zien als ik een pagina opvraag. Lijkt me dus dat het request helemaal niet wordt doorgestuurd naar php.

Acties:
  • 0 Henk 'm!

  • Hero of Time
  • Registratie: Oktober 2004
  • Laatst online: 18:46

Hero of Time

Moderator LNX

There is only one Legend

Apache valt onder de server software, dus ik tik deze even door naar WSS.

Commandline FTW | Tweakt met mate


Acties:
  • 0 Henk 'm!

  • uashy
  • Registratie: Mei 2002
  • Laatst online: 31-05 17:44
Ik neem aan dat je al gecontroleerd hebt dat er een proces luistert op poort 9000?
Enige dat me zo opvalt aan de logs, is dat met php 5.4 de referrer wel gevuld is, maar met php 5.2 niet.
Maar kan dan niet verklaren hoe dat voor dit probleem kan zorgen.

Meest waarschijnlijke lijkt me dat de combinatie apache 2.4 en php 5.2 niet lekker werkt. Misschien moet er een specifieke parameter gebruikt moet worden bij de compilatie? Weet daar onvoldoende van om je advies te geven.

Acties:
  • 0 Henk 'm!

  • Hero of Time
  • Registratie: Oktober 2004
  • Laatst online: 18:46

Hero of Time

Moderator LNX

There is only one Legend

Toevallig, met uashy's opmerking heb ik even gezocht naar die combinatie en je moet php 5.2 patchen voordat 't gaat werken. Je zegt niet dat je dat hebt gedaan, alleen dat je ze alle 4 zelf gecompileerd hebt (weet je dat je daar heel veel onderhoud mee creëert?). Zie http://www.apachelounge.com/viewtopic.php?t=4756 voor de patch die iemand heeft geschreven voor 5.2 en 5.3.

Commandline FTW | Tweakt met mate


Acties:
  • 0 Henk 'm!

  • bennierex
  • Registratie: April 2001
  • Laatst online: 13-10 10:59
Hero Of Time schreef op woensdag 30 januari 2013 @ 19:59:
Toevallig, met uashy's opmerking heb ik even gezocht naar die combinatie en je moet php 5.2 patchen voordat 't gaat werken. Je zegt niet dat je dat hebt gedaan, alleen dat je ze alle 4 zelf gecompileerd hebt (weet je dat je daar heel veel onderhoud mee creëert?). Zie http://www.apachelounge.com/viewtopic.php?t=4756 voor de patch die iemand heeft geschreven voor 5.2 en 5.3.
Qua onderhoud: ja dat weet ik. Vanwege specifieke configuraties/versies kan dat helaas niet anders.

Ik heb een andere patch toegepast (weet zo even uit mn hoofd niet meer waar vandaan), maar ik ga vanmiddag die uit jouw linkje eens proberen. Bedankt!

Acties:
  • 0 Henk 'm!

  • bennierex
  • Registratie: April 2001
  • Laatst online: 13-10 10:59
Eindelijk, problem solved! :*)

Mocht er ooit nog iemand hier terecht komen met hetzelde probleem:

Het zit hem in de manier waarop de Apache 2.4 mod_proxy_fcgi de requests doorgeeft aan de PHP fpm. Het request ziet er als volgt uit: "proxy:fcgi://localhost:9000/some-dir/info.php/test" en moet voor php worden herleid naar "/some-dir/info.php/test" om de docroot en scriptname te kunnen ontcijferen. Nu zijn de laatste versies van PHP 5.3 en 5.4 netjes gepatched, maar bij 5.2 is dit niet het geval. Daarom heb ik de source handmatig aangepast aan de hand van een patch voor 5.3.

Wat ik heb gedaan:De patch als unified-diff:
C:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@@ -942,6 +942,7 @@
    char *env_script_filename = sapi_cgibin_getenv("SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1 TSRMLS_CC);
    char *env_path_translated = sapi_cgibin_getenv("PATH_TRANSLATED", sizeof("PATH_TRANSLATED")-1 TSRMLS_CC);
    char *script_path_translated = env_script_filename;
+   int apache_was_here = 0;
 
 #if !DISCARD_PATH
    /* some broken servers do not have script_filename or argv0
@@ -993,6 +994,30 @@
            env_path_info = _sapi_cgibin_putenv("PATH_INFO", env_path_info TSRMLS_CC);
        }
 
+       #define APACHE_PROXY_FCGI_PREFIX "proxy:fcgi://"
+       /* Fix proxy URLs in SCRIPT_FILENAME generated by Apache mod_proxy_fcgi:
+        *     proxy:fcgi://localhost:9000/some-dir/info.php/test
+        * should be changed to:
+        *     /some-dir/info.php/test
+        * See: http://bugs.php.net/bug.php?id=54152
+        *      https://issues.apache.org/bugzilla/show_bug.cgi?id=50851
+        */
+       if (env_script_filename &&
+           strncasecmp(env_script_filename, APACHE_PROXY_FCGI_PREFIX, sizeof(APACHE_PROXY_FCGI_PREFIX) - 1) == 0) {
+           /* advance to first character of hostname */
+           char *p = env_script_filename + (sizeof(APACHE_PROXY_FCGI_PREFIX) - 1);
+           while (*p != '\0' && *p != '/') {
+               p++;    /* move past hostname and port */
+           }
+           if (*p != '\0') {
+               /* Copy path portion in place to avoid memory leak.  Note
+                * that this also affects what script_path_translated points
+                * to. */
+               memmove(env_script_filename, p, strlen(p) + 1);
+               apache_was_here = 1;
+           }
+       }
+
        if (CGIG(fix_pathinfo)) {
            char *real_path = NULL;
            char *orig_path_translated = env_path_translated;
@@ -1059,11 +1084,21 @@
                         * we have to play the game of hide and seek to figure
                         * out what SCRIPT_NAME should be
                         */
-                       int slen = len - strlen(pt);
+                       int ptlen = strlen(pt);
+                       int slen = len - ptlen;
                        int pilen = env_path_info ? strlen(env_path_info) : 0;
-                       char *path_info = env_path_info ? env_path_info + pilen - slen : NULL;
+                       int tflag = 0;
+                       char *path_info;
+                       if (apache_was_here) {
+                           /* recall that PATH_INFO won't exist */
+                           path_info = script_path_translated + ptlen;
+                           tflag = (slen != 0 && (!orig_path_info || strcmp(orig_path_info, path_info) != 0));
+                       } else {
+                           path_info = env_path_info ? env_path_info + pilen - slen : NULL;
+                           tflag = (orig_path_info != path_info);
+                       }
 
-                       if (orig_path_info != path_info) {
+                       if (tflag) {
                            if (orig_path_info) {
                                char old;
Hero Of Time schreef op woensdag 30 januari 2013 @ 19:59:
Toevallig, met uashy's opmerking heb ik even gezocht naar die combinatie en je moet php 5.2 patchen voordat 't gaat werken. Je zegt niet dat je dat hebt gedaan, alleen dat je ze alle 4 zelf gecompileerd hebt (weet je dat je daar heel veel onderhoud mee creëert?). Zie http://www.apachelounge.com/viewtopic.php?t=4756 voor de patch die iemand heeft geschreven voor 5.2 en 5.3.
Dit zijn patches voor het gebruik als mod_php onder apache, maar je hebt me wel geholpen want het was net het duwtje in de juiste riching. :)

Bedankt!
Pagina: 1