LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-18-2014, 06:47 PM   #1
dfresh
LQ Newbie
 
Registered: Oct 2005
Posts: 5

Rep: Reputation: 0
Modify apache config files on start


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:
Code:
ENVT=test
Then in the apache config files I have values like:
Code:
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.

Code:
if [ ${ENVT} == prod ]; then
 `/bin/sed -r 's/\.\$\{ENVT\}//g' /apps/httpd/conf.d/*.conf`
fi
 
Old 04-19-2014, 01:15 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Use an external file - if it exists use ". <path>testserver.conf" to include it.

If it doesn't exist, use the host name and set the parameter.
 
  


Reply

Tags
apache, httpdconf, sed bash



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
Allow ftp user access to modify apache owned files jasonma84@yahoo.com Linux - Newbie 4 10-26-2010 04:25 PM
system-config-httpd in RHEL5 - cant start apache :( BigG Red Hat 13 01-31-2008 06:31 PM
which config files to modify?? linuxnewbie82 Fedora 3 07-13-2006 04:04 PM
Apache 2 Config Files waynejkruse10 Linux - Software 5 05-24-2005 02:20 PM
locating linux config files and how to modify a bash kernel maelstrombob Linux - Newbie 1 11-18-2003 09:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration