homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Modify apache config files on start
apache config start

 7:57 pm on Apr 23, 2014 (gmt 0)

In my test environments I'm using variables for the basic apache configs. In my init.d startup script I just export some variables like:

Then in the apache config files I have values like:
ServerName www.${ENVT}.abc.com

This is working fine however I'm a bit stumped as to how I can have that variable removed when it comes to production where it should be just www.abc.com. Is there a way I can modify my startup script to run a sed command on the file to load into memory instead of actually modifying the copy on disk? The sed command below works; I just need to figure out if it's possible to have the apache config files modified before the binary reads them. Feels like something fairly simple I'm missing, but maybe not. Or maybe I'm just taking the wrong approach.

if [ ${ENVT} == prod ]; then
`/bin/sed -r 's/\.\$\{ENVT\}//g' /apps/httpd/conf.d/*.conf`



 9:21 pm on Apr 23, 2014 (gmt 0)

ServerName www.${ENVT}.abc.com

The thought that jumped out at me was: Why not include a trailing or leading . in the variable value itself? Then if the variable is empty, it's as if the whole thing didn't exist.

Obviously this doesn't remove the variable. It just makes it irrelevant.

Obligatory disclaimer: I don't speak Apache, so I don't know whether this would make the server explode.


 12:54 am on Apr 24, 2014 (gmt 0)

I would set the environment variiable differently in production and test environments:

then in the apache config files use:
ServerName ${ENVT}.example.com

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved