[英]Environment variables readable by Apache/PHP and Systemd/node
On the same server, I have a apache php application and a nodejs application (started via systemd). 在同一台服务器上,我有一个Apache php应用程序和一个nodejs应用程序(通过systemd启动)。
For systemd/node, I put the following config: 对于systemd / node,我输入以下配置:
[Service]
EnvironmentFile=/etc/environment
For apache, I have put the following line in /etc/apache2/envvars
对于apache,我将以下行放在
/etc/apache2/envvars
. /etc/environment
My problem is: 我的问题是:
export
before each variable, but not in node via systemd export
放在每个变量之前,则它可以在PHP和独立节点中使用,但不能通过systemd在节点中使用 export
export
它将通过systemd在节点中工作 Is there a way for me to write these variables in a single place that can be used by Apache/PHP and node started via systemd ? 有没有办法在一个地方写这些变量,Apache / PHP可以使用这些变量,并且可以通过systemd启动节点?
You can use the export statement version of your environent file if you change your ExecStart=
line to something like: ExecStart=/bin/sh -c ". /etc/environment && exec /PATH/TO/NODEJS/APPLICATION"
. 如果将
ExecStart=
行更改为类似以下ExecStart=/bin/sh -c ". /etc/environment && exec /PATH/TO/NODEJS/APPLICATION"
则可以使用环境文件的导出语句版本: ExecStart=/bin/sh -c ". /etc/environment && exec /PATH/TO/NODEJS/APPLICATION"
。 This is kludgy though. 不过这很糊涂。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.