简体   繁体   中英

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).

For systemd/node, I put the following config:

[Service]
EnvironmentFile=/etc/environment

For apache, I have put the following line in /etc/apache2/envvars

. /etc/environment

My problem is:

  • It works in PHP and standalone node if I put export before each variable, but not in node via systemd
  • It works in node via systemd if I remove the export

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 ?

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" . This is kludgy though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM