LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 08-29-2009, 09:01 AM   #1
breeze99
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Rep: Reputation: 0
apache: Is apache config accepting shell env vars ?


Linux x86_64 GNU/Linux , Server version: Apache/2.2.8 (Linux/SUSE)

Is there a method to pass to apache config, shell env var in place of hardcoded value ?

For examp I want apache reffer to config file defined by env var $PATH_TO_MY_LOCAL_CONFIG:
#######################################################################
Code:
tcsh> setenv PATH_TO_MY_LOCAL_CONFIG /mydir/my_ver_0.1/httpd.conf.local
tcsh> vim /etc/apache2/httpd.conf

PassEnv PATH_TO_MY_LOCAL_CONFIG
Include $PATH_TO_MY_LOCAL_CONFIG
:wq

tcsh> apache2ctl -k start
httpd2: Syntax error on line 214 of /etc/apache2/httpd.conf: Could not open configuration file /srv/www/$PATH_TO_MY_LOCAL_CONFIG: No such file or directory
tcsh>
#####################################################################

tnx.
 
Old 08-29-2009, 05:08 PM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,894

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Apache has its own env. variables, but they cannot do what you want. Also you can use shell env. variables, but only for CGIs and SSIs
In your case, can use your env. variables in a script or CLI. For example (in bash):
Code:
export PATH_TO_MY_LOCAL_CONFIG=/mydir/my_ver_0.1/httpd.conf.local
httpd -k start -c "Include PATH_TO_MY_LOCAL_CONFIG"
Regards

Last edited by bathory; 08-29-2009 at 05:11 PM.
 
Old 08-30-2009, 04:28 PM   #3
breeze99
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for replay,
Finally thats worked .. (believe or not ) )
Just share w/u my exp..
I did 2 thinks :
##################################################
<CODE>
1. Added module that support envs:
Should exists: /usr/lib64/apache2-prefork/mod_env.so
vim /etc/sysconfig/apache2
APACHE_MODULES=".. .. .. env .. .."
:wq
vim /etc/apache2/sysconfig.d/loadmodule.conf
LoadModule env_module /usr/lib64/apache2-prefork/mod_env.so
:wq
2. Added directive and fixed syntax , env vars should be enclosed by curly brackets :
vim /etc/apache2/httpd.conf
PassEnv PATH_TO_MY_LOCAL_CONFIG <== (directive to provide env var)
Include ${PATH_TO_MY_LOCAL_CONFIG} <== (should be in curly brackets)
:wq
</CODE>
####################################################
Now after starting apache2ctl its loaded all setings that coming
from file refered by $PATH_TO_MY_LOCAL_CONFIG
Thats good feature, now I can conditionally define config by changing shell var without touching http.conf it self.

Thanks.
~
 
  


Reply

Tags
apacheconf


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Not Accepting Requests Mytob Linux - Newbie 4 05-21-2009 07:44 AM
Inserting ENV. VARS. for all of Linux to use Last Attacker Linux - General 3 02-01-2007 01:57 PM
env vars on Slackware 10 lvella Linux - General 1 11-01-2004 04:55 PM
init on boot programs that need env vars The_Spider Linux - General 3 04-29-2004 07:30 AM
apache don't read get/post vars batosti Slackware 1 08-16-2003 11:04 AM


All times are GMT -5. The time now is 08:45 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration