You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2017/06/27 21:04:29 UTC
svn commit: r1800088 - in /httpd/test/framework/trunk/t: conf/ htdocs/fpm/
htdocs/fpm/sub1/ htdocs/fpm/sub1/sub2/ modules/ php-fpm/ php-fpm/etc/
php-fpm/etc/php-fpm.d/ php-fpm/log/ php-fpm/pools/ php-fpm/pools/www/
php-fpm/run/ php-fpm/var/ php-fpm/var...
Author: jim
Date: Tue Jun 27 21:04:28 2017
New Revision: 1800088
URL: http://svn.apache.org/viewvc?rev=1800088&view=rev
Log:
OK, add in capability to actually call PHP-FPM via
fcgi if available... Now we need to determine the
various settings (GENERIC vs PHP-FPM) and expected
values but at least we have a framework of sorts.
Added:
httpd/test/framework/trunk/t/htdocs/fpm/
httpd/test/framework/trunk/t/htdocs/fpm/sub1/
httpd/test/framework/trunk/t/htdocs/fpm/sub1/sub2/
httpd/test/framework/trunk/t/htdocs/fpm/sub1/sub2/test.php
httpd/test/framework/trunk/t/htdocs/fpm/test.php
httpd/test/framework/trunk/t/php-fpm/
httpd/test/framework/trunk/t/php-fpm/etc/
httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.conf
httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.d/
httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.d/www.conf
httpd/test/framework/trunk/t/php-fpm/fcgi.pl (with props)
httpd/test/framework/trunk/t/php-fpm/log/
httpd/test/framework/trunk/t/php-fpm/pools/
httpd/test/framework/trunk/t/php-fpm/pools/www/
httpd/test/framework/trunk/t/php-fpm/run/
httpd/test/framework/trunk/t/php-fpm/var/
httpd/test/framework/trunk/t/php-fpm/var/log/
Modified:
httpd/test/framework/trunk/t/conf/proxy.conf.in
httpd/test/framework/trunk/t/modules/proxy_fcgi.t
Modified: httpd/test/framework/trunk/t/conf/proxy.conf.in
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/conf/proxy.conf.in?rev=1800088&r1=1800087&r2=1800088&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/conf/proxy.conf.in (original)
+++ httpd/test/framework/trunk/t/conf/proxy.conf.in Tue Jun 27 21:04:28 2017
@@ -99,6 +99,11 @@
</IfModule>
<IfModule mod_actions.c>
+ #AddType application/x-php-fpm .php
+ Action application/x-php-fpm /fpm virtual
+ <Location /fpm>
+ SetHandler proxy:fcgi://localhost:9001
+ </Location>
<Directory @SERVERROOT@/htdocs/modules/proxy/fcgi-action>
AddType application/x-fcgi-action .php
Action application/x-fcgi-action /fcgi-action-virtual virtual
Added: httpd/test/framework/trunk/t/htdocs/fpm/sub1/sub2/test.php
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/htdocs/fpm/sub1/sub2/test.php?rev=1800088&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/htdocs/fpm/sub1/sub2/test.php (added)
+++ httpd/test/framework/trunk/t/htdocs/fpm/sub1/sub2/test.php Tue Jun 27 21:04:28 2017
@@ -0,0 +1,4 @@
+<?php
+ foreach ($_SERVER as $key => $value) {
+ echo "$key=$value\n";
+ }
\ No newline at end of file
Added: httpd/test/framework/trunk/t/htdocs/fpm/test.php
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/htdocs/fpm/test.php?rev=1800088&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/htdocs/fpm/test.php (added)
+++ httpd/test/framework/trunk/t/htdocs/fpm/test.php Tue Jun 27 21:04:28 2017
@@ -0,0 +1 @@
+<?php var_export($_SERVER)?>
Modified: httpd/test/framework/trunk/t/modules/proxy_fcgi.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/proxy_fcgi.t?rev=1800088&r1=1800087&r2=1800088&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/modules/proxy_fcgi.t (original)
+++ httpd/test/framework/trunk/t/modules/proxy_fcgi.t Tue Jun 27 21:04:28 2017
@@ -9,10 +9,12 @@ use Misc;
my $have_fcgisetenvif = have_min_apache_version('2.4.26');
my $have_fcgibackendtype = have_min_apache_version('2.4.26');
+my $have_php_fpm = `php-fpm -v` =~ /fpm-fcgi/;
plan tests => (7 * $have_fcgisetenvif) + (2 * $have_fcgibackendtype) +
(2 * $have_fcgibackendtype * have_module('rewrite')) +
- (7 * have_module('rewrite')) + (7 * have_module('actions')) + 2,
+ (7 * have_module('rewrite')) + (7 * have_module('actions')) +
+ (2 * $have_php_fpm) + 2,
need (
'mod_proxy_fcgi',
'FCGI',
@@ -81,7 +83,7 @@ sub run_fcgi_envvar_request($$)
my $uri = shift;
# Launch the FCGI process.
- my $child = launch_envvar_echo_daemon($fcgi_port);
+ my $child = launch_envvar_echo_daemon($fcgi_port) unless ($fcgi_port == -1) ;
# Hit the backend.
my $r = GET($uri);
@@ -98,7 +100,7 @@ sub run_fcgi_envvar_request($$)
}
# Rejoin the child FCGI process.
- waitpid($child, 0);
+ waitpid($child, 0) unless ($fcgi_port == -1) ;
return \%envs;
}
@@ -114,6 +116,7 @@ sub run_fcgi_envvar_request($$)
my $fcgi_port = Apache::Test::vars('proxy_fcgi_port') - 1;
my $envs;
my $docroot = Apache::Test::vars('documentroot');
+my $servroot = Apache::Test::vars('serverroot');
if ($have_fcgisetenvif) {
# ProxyFCGISetEnvIf tests. Query the backend.
@@ -197,5 +200,15 @@ if (have_module('actions')) {
# Regression test for PR61202.
$envs = run_fcgi_envvar_request($fcgi_port, "/modules/proxy/fcgi/index.php");
-
ok t_cmp($envs->{'SCRIPT_NAME'}, '/modules/proxy/fcgi/index.php', "Server sets correct SCRIPT_NAME by default");
+
+# Testing using php-fpm directly
+if ($have_php_fpm) {
+ Misc::do_do_run_run("php-fpm", sub { system "php-fpm -F -p $servroot/php-fpm"; });
+ sleep 1; # Yes, we really need this here since php-fpm takes a while
+ $envs = run_fcgi_envvar_request(-1, "/fpm/sub1/sub2/test.php?query");
+ # NOTE: Magic location!! See www.conf in t/php-fpm/etc/php-fpm.d
+ # TODO: Make this less magical
+ kill 'TERM', `cat /tmp/httpd-test-php-fpm.pid`;
+ ok t_cmp($envs->{'SCRIPT_NAME'}, '/fpm/sub1/sub2/test.php', "Server sets correct SCRIPT_NAME by default");
+}
Added: httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.conf
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.conf?rev=1800088&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.conf (added)
+++ httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.conf Tue Jun 27 21:04:28 2017
@@ -0,0 +1,19 @@
+;;;;;;;;;;;;;;;;;;;;;
+; FPM Configuration ;
+;;;;;;;;;;;;;;;;;;;;;
+
+; All relative paths in this configuration file are relative to PHP's install
+; prefix (/usr/local). This prefix can be dynamically changed by using the
+; '-p' argument from the command line.
+
+;;;;;;;;;;;;;;;;;;
+; Global Options ;
+;;;;;;;;;;;;;;;;;;
+
+[global]
+
+error_log = log/php-fpm.log
+syslog.ident = php-fpm
+log_level = notice
+daemonize = no
+include=etc/php-fpm.d/*.conf
Added: httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.d/www.conf
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.d/www.conf?rev=1800088&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.d/www.conf (added)
+++ httpd/test/framework/trunk/t/php-fpm/etc/php-fpm.d/www.conf Tue Jun 27 21:04:28 2017
@@ -0,0 +1,8 @@
+; Start a new pool named 'www'.
+; the variable $pool can be used in any directive and will be replaced by the
+; pool name ('www' here)
+pid = /tmp/httpd-test-php-fpm.pid
+[www]
+listen = 127.0.0.1:9001
+pm = static
+pm.max_children = 1
Added: httpd/test/framework/trunk/t/php-fpm/fcgi.pl
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/php-fpm/fcgi.pl?rev=1800088&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/php-fpm/fcgi.pl (added)
+++ httpd/test/framework/trunk/t/php-fpm/fcgi.pl Tue Jun 27 21:04:28 2017
@@ -0,0 +1,25 @@
+#!/usr/bin/env perl
+use FCGI;
+use Socket;
+use FCGI::ProcManager;
+use Data::Dumper;
+
+$num_args = $#ARGV + 1;
+if ($num_args != 1) {
+ print "\nUsage: fcgi.pl <socket>\n";
+ exit 1;
+}
+
+$proc_manager = FCGI::ProcManager->new( {n_processes => 1} );
+$socket = FCGI::OpenSocket( $ARGV[0], 10 );
+$request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%req_params,
+$socket, &FCGI::FAIL_ACCEPT_ON_INTR );
+$proc_manager->pm_manage();
+if ($request) {
+ while ( $request->Accept() >= 0 ) {
+ $proc_manager->pm_pre_dispatch();
+ print("Content-type: text/plain\r\n\r\n");
+ print Dumper(\%req_params);
+ }
+}
+FCGI::CloseSocket($socket);
Propchange: httpd/test/framework/trunk/t/php-fpm/fcgi.pl
------------------------------------------------------------------------------
svn:executable = *