我看到这些文档: https://httpd.apache.org/docs/current/mod/mod_env.html
我希望从主机继承/传递所有环境变量到apache,以便可以在CGI脚本中访问它们。现在,cgi脚本将像这样记录环境变量:
#!/usr/bin/env bash
env | sort | while read line; echo "$line <br>"; done
但是当cgi脚本运行该脚本时,它仅记录与apache / httpd有关的env变量,没有记录来自外部环境的env变量,但是为什么?
所以我想正在做类似的事情:
PassEnv *
但这只是一个猜测,有人知道可能会传递所有env变量的东西吗?
具体来说,我们正在使用Kubernetes /(AWS EKS),这是我们的副本/吊舱配置:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: apache-spike
spec:
replicas: 3
template:
metadata:
labels:
app: apache-spike
spec:
containers:
- name: apache-spike
image: 913617820371.dkr.ecr.us-west-2.amazonaws.com/interos_apache:latest
ports:
- name: http-port
containerPort: 8080
protocol: TCP
imagePullPolicy: Always
env:
- name: DEMO_GREETING
value: "Hello from the environment"
- name: DEMO_FAREWELL
value: "demo farewell env var"
当我们描述其中一个吊舱时,我们看到:
Containers:
apache-spike:
Container ID: docker://6727d6eafe2a6d229c58875c8cf2c2e9a0cff517dbe67600f965fe19eee000c1
Image: 9136xxxx0371.dkr.ecr.us-west-2.amazonaws.com/interos_apache:latest
Image ID: docker-pullable://9136xxxx0371.dkr.ecr.us-west-2.amazonaws.com/interos_apache@sha256:74f6cab7ef4e1b93123c6e61c7cbdbe5960b736f7e26e075ea5031fb838437be
Port: 8080/TCP
Host Port: 0/TCP
State: Running
Started: Tue, 07 May 2019 17:12:07 -0700
Ready: True
Restart Count: 0
Environment:
DEMO_GREETING: Hello from the environment
DEMO_FAREWELL: demo farewell env var
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-jhvnp (ro)
因此,至少存在环境变量。
当我在Pod上运行此命令时:
kubectl exec apache-spike-579598949b-5bjjs -c apache-spike -- sh -c 'id && ps -e'
我明白了:
uid=0(root) gid=0(root) groups=0(root)
PID TTY TIME CMD
1 ? 00:00:04 httpd
7 ? 00:00:00 httpd
8 ? 00:00:11 httpd
9 ? 00:00:09 httpd
10 ? 00:00:09 httpd
92 ? 00:00:13 httpd
204 ? 00:00:00 sh
211 ? 00:00:00 ps