Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F11722167
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/files/etc/service/php-fpm/run b/files/etc/service/php-fpm/run
index 3e660e1..e440441 100755
--- a/files/etc/service/php-fpm/run
+++ b/files/etc/service/php-fpm/run
@@ -1,4 +1,5 @@
#!/bin/bash
exec 2>&1
source /usr/local/etc/envvars
+php-fpm-env > /usr/local/etc/php-fpm-env.conf
exec /usr/local/sbin/php-fpm --nodaemonize
diff --git a/files/usr/local/etc/php-fpm.conf b/files/usr/local/etc/php-fpm.conf
index 751e85b..149df8c 100644
--- a/files/usr/local/etc/php-fpm.conf
+++ b/files/usr/local/etc/php-fpm.conf
@@ -1,16 +1,13 @@
[app]
listen = 127.0.0.1:9000
user = app
group = app
pm = ondemand
pm.max_children = 10
pm.process_idle_timeout = 60
pm.max_requests = 500
php_admin_flag[cgi.fix_pathinfo] = off
-env[HOSTNAME] = $HOSTNAME
-env[PATH] = /usr/local/bin:/usr/bin:/bin
-env[TMP] = /tmp
-env[TMPDIR] = /tmp
-env[TEMP] = /tmp
+include=etc/php-fpm-env.conf
+
diff --git a/files/usr/local/lib/php-fpm-env/PhpFpmEnvironment.php b/files/usr/local/lib/php-fpm-env/PhpFpmEnvironment.php
new file mode 100755
index 0000000..a05486d
--- /dev/null
+++ b/files/usr/local/lib/php-fpm-env/PhpFpmEnvironment.php
@@ -0,0 +1,76 @@
+#!/usr/bin/env php
+<?php
+
+/**
+ * Allows to get the content of a php-fpm environment configuration file
+ */
+class PhpFpmEnvironment {
+ /**
+ * The temporary directory, used in TMP, TEMP and TMPDIR environment variables
+ * @var string
+ */
+ const TMP = '/tmp';
+
+ /**
+ * The path where to find executables, where sbin should be excluded if you don't run PHP as root.
+ * @var string
+ */
+ const PATH = '/usr/local/bin:/usr/bin:/bin';
+
+ /**
+ * The environment variables to discard
+ * @var Array
+ */
+ const VARIABLES_TO_DISCARD = [
+ '_', // The caller executable script, not pertinent
+ 'HOME', // Set correctly by php-fpm
+ 'TERM', // Not pertinent in server context
+ 'MYSQL_ENV_MYSQL_ROOT_PASSWORD', // from --link …:mysql
+ ];
+
+ /**
+ *ets an environment array from the current process environment,
+ * with PATH and temp variablesfiltered.
+ *
+ * @return Array
+ */
+ public static function getEnvironmentVariables () {
+ $variables = [];
+
+ foreach ($_ENV as $key => $value) {
+ if (static::mustIgnoreVariable($key)) {
+ continue;
+ }
+
+ $variables[$key] = $value;
+ }
+
+ $variables['PATH'] = static::PATH;
+ $variables['TMP'] = static::TMP;
+ $variables['TEMP'] = static::TMP;
+ $variables['TMPDIR'] = static::TMP;
+
+ return $variables;
+ }
+
+ /**
+ * Determines if the variable name must be ignored
+ *
+ * @return bool true if the variable must be ignored; otherwise, false.
+ */
+ public static function mustIgnoreVariable ($variableName) {
+ return in_array($variableName, static::VARIABLES_TO_DISCARD);
+ }
+
+ /**
+ * Gets the environment
+ */
+ public static function get () {
+ $variables = static::getEnvironmentVariables();
+ foreach ($variables as $key => $value) {
+ echo 'env["', $key, '"] = "', $value, '"', PHP_EOL;
+ }
+ }
+}
+
+PhpFpmEnvironment::get();
diff --git a/files/usr/local/sbin/php-fpm-env b/files/usr/local/sbin/php-fpm-env
new file mode 120000
index 0000000..09e4c0b
--- /dev/null
+++ b/files/usr/local/sbin/php-fpm-env
@@ -0,0 +1 @@
+../lib/php-fpm-env/PhpFpmEnvironment.php
\ No newline at end of file
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Sep 18, 01:33 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2989706
Default Alt Text
(3 KB)
Attached To
Mode
rDPHPVIIFPM Docker image to install nginx, PHP 7 and fpm
Attached
Detach File
Event Timeline
Log In to Comment