我正在尝试修改 CentOS 7 上的文件 /etc/sysconfig/httpd。
此文件修改了systemd下httpd服务的环境。
我想通过添加来修改 PATH 变量。我可以设置它,但我在寻找正确的语法来添加它。
如果我使用这个:
PATH="/export/home/www/perl5/bin:$PATH"
..那么我在 Apache 上的 PATH 中得到的内容实际上是:
/export/home/www/perl5/bin:$PATH
换句话说,它没有插入 $PATH 变量。
我尝试了许多不同的语法,但仍然无法让它发挥作用。
有人知道正确的语法吗?
答案1
设置 Environment= 时,systemd 不支持变量扩展。解决方法是只说明您需要设置的完整路径集。
否则,您粘贴的内容/etc/sysconfig/httpd
看起来对过渡到 Apache 有很好的建议,由systemd
答案2
man /etc/sysconfig/httpd
# # This file is no longer used to configure additional environ‐
ment variables # for the httpd process. # # It has been replaced
by systemd. If you want to customize, the best # way is to create
a file "/etc/systemd/system/httpd.service", # containing # .in‐
clude /lib/systemd/system/httpd.service # ...make your changes
here... # For more info about custom unit files, see #
http://fedoraproject.org/wiki/Systemd#How_do_I_custom‐
ize_a_unit_file.2F_add_a_custom_unit_file.3F
# To set OPTIONS environment variable which was set in this file
# in older versions, you need to create a file named # "/etc/sys‐
temd/system/httpd.service" containing: # .include /lib/sys‐
temd/system/httpd.service # [Service] # # # #
To pass additional options (for instance, ‐D definitions) to the
# # httpd binary at startup, set OPTIONS here. # #
# Environment=OPTIONS=‐DMY_DEFINE
# Note: With previous versions of httpd, the MPM could be changed
by # editing an "HTTPD" variable here. With the current version,
that # variable is now ignored. The MPM is a loadable module,
and the # choice of MPM can be changed by editing the configura‐
tion file # /etc/httpd/conf.modules.d/00‐mpm.conf. #
这是来自 fedora 23,但我确信它足够相似,可以给你指点,否则请在你的机器上自己运行“man /etc/systemd/httpd”。