0

I am trying to modify the file /etc/sysconfig/httpd on CentOS 7.

This file modifies the environment for the httpd service under systemd.

I want to modify the PATH variable by adding to it. I can set it, but I am struggling with the right syntax to add to it.

If I use this:

PATH="/export/home/www/perl5/bin:$PATH"

..then what I get in PATH on Apache is actually:

/export/home/www/perl5/bin:$PATH

In other words, it is not interpolating the $PATH variable.

I have tried a bunch of different syntaxes, but I haven't got it to work yet.

Does anybody know the correct syntax?

1

systemd does not support variable expansion when setting Environment=. The workaround is to just spell out the full set of paths you need to set.

Otherwise, the contents of /etc/sysconfig/httpd you pasted looks like it has good advice on the transition to Apache being managed by systemd

0
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.  #

This is from fedora 23, but I'm sure it's similar enough to give you pointers, else run "man /etc/systemd/httpd" yourself on your machine.

  • This is just the contents of the file. I'm not seeing the specification of the correct syntax to do what I want to do here. If I'm missing it, I might need it spelled out to me a bit more. Same on my own machine: just the contents of the file. – Richard of Essex Jun 29 '16 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.