Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Editing the Apache config from a bash script: how to append infos to an existing file ?

Avatar of Denisvt
Denisvt asked on
Scripting LanguagesShell Scripting
3 Comments1 Solution577 ViewsLast Modified:
Hello to all

I am writing a Command Line (Bash) script to automate a blog installation on a Linux server.
So far so good, except that I would like the Apache conf file to be changed too so that I can immediately reload my Web server and have the new hosting functional.
Therefore I must add a few lines at the end of the /etc/apache/httpd.conf file:

<VirtualHost 1.2.3.4.5.6:80>
ServerName myblogsite.fr
DocumentRoot /home/myblogsite.fr/www
(...)
</VirtualHost>

Is it possible to edit that Apache conf directly from my bash script ? I already know how to backup my apache conf, and I currently even already log that required Apache Virtual host info in a file, from which I just copy and paste - see quoted code. What I need is to be able to append that new info exactly at the end of my existing httpd.conf file
Who could point me on how to do that ?

Thanks !
cat <<EOT >${MYPATH}/setupvh_${MYBLOGSITE}.txt
<VirtualHost 1.2.3.4.5.6:80>
ServerName myblogsite.fr
DocumentRoot /home/myblogsite.fr/www
(...)
</VirtualHost>
EOT
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers