Martin Dellwo on 12 Mar 2013 19:40:35 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Setting an environment variable for servers on Linux...

So much for one Linux standard.  The init/rc stuff is all over the map.  Recent Fedora uses systemctl stuff and I have no idea where you set env variables for that.  But irrelevant--that won't work for regular users.  I would suggest putting it in profile.d.  And if Apache doesn't pick that up, there's some sort of SETENV directive you can put directly in your Apache config...  oh, but maybe that doesn't help you if you need it for the startup process itself.

On Mar 12, 2013, at 10:32 PM, Eric at <> wrote:

Hash: SHA1


I'm not qualified to answer this.
Having stated my disclaimer, it's an interesting question and so I'm thinking out loud...

The following article mentions inittab:
but inittab is missing in modern Debian/Ubuntu.  What about /etc/init/rc.conf ?  There
are a couple of export statements in there.  Since init is the first "userspace" program and
the parent to all subsequent processes it seems like a good location to start.

Ah, now Rich mentions /etc/env.d - but I don't have that in my Linux Mint 13 system.
There is /etc/init/rc.conf with a couple of "export" statements.

HTH and good luck.

On 03/12/2013 09:16 PM, Matt Murphy wrote:
Those rc#.d scripts define environments for individual processes, I think.  I don't think there's a quick way to do what you want to do.  Anyone?


On Tue, Mar 12, 2013 at 4:42 PM, Fred Stluka < <>> wrote:

PLUG folks,

What's the best way to set an environment variable on Linux, so that it is found not only by shells, but also for servers processes like Apache?

I have created: /etc/profile.d/ export HHL_ENVIRONMENT=test /etc/profile.d/hhl.csh setenv HHL_ENVIRONMENT test so now when any user logs in with any sh- or csh-based shell, the env var is defined.

However, Apache and other servers are launched at boor time via scripts and symlinks in /etc/rc.d, and they do NOT pick up the env var.

Is there a single place to define it so all processes see it?  Or should I just add the line: . /etc/profile.d/ to each of the appropriate files in: /etc/rc.d/init.d

I googled a bit and didn't find any better answer.

Any thoughts?  Thanks! --Fred ------------------------------__------------------------------__------------ Fred Stluka -- <> -- Bristle Software, Inc -- -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. ------------------------------__------------------------------__------------ _______________________________________________________________________________ Philadelphia Linux Users Group         -- Announcements - <> General Discussion  -- <>

___________________________________________________________________________ Philadelphia Linux Users Group         -- Announcements - General Discussion  --

- --
#  Eric Lucas
#     I'm confessin' I never took a lesson,
#     All my notes are a matter of guessin'
#     Hopin' they'll come out in some kinda manner
#     that'll make that yakety sound.
#       - Boots Randolph, Merle Travis, Chet Atkins, Mark Knopfler
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird -

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --

Martin Dellwo
cell: (484) 437-3662

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --