You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Agnello George <ag...@gmail.com> on 2008/06/18 15:39:18 UTC

[users@httpd] editing httpd.conf file through shell script

hi

i am trying to edit my httpd.comf file through a shell script ......      ((
actually I trying to set up a control panel ))

my httpd.conf host directives for many domains  , the file is  something
like this :


##########START#######rodney.com###################

<VirtualHost 192.168.0.244:80 <http://192.168.0.244/>>
ServerAdmin admin@ashish.sys.qualiproj.com
ServerName rodney.sys.qualiproj.qualispace.com
ServerAlias www.rodney.sys.qualiproj.qualispace.com
DocumentRoot /websites/rodney.com/web
ErrorLog /websites/rodney.com/logs/rodney.sys.qualiproj.error_log
CustomLog /websites/rodney.com/logs/rodney.sys.qualiproj.access_log common
</VirtualHost>
##########END############rodney.com###################


#########START#########vodafone###################

<VirtualHost 192.168.0.244:80 <http://192.168.0.244/>>
ServerAdmin admin@ashish.sys.qualiproj.com
ServerName fff.sys.qualiproj.qualispace.com
ServerAlias www.fff.sys.qualiproj.qualispace.com
DocumentRoot /websites/vodafone/web
ErrorLog /websites/vodafone/logs/fff.sys.qualiproj.error_log
CustomLog /websites/vodafone/logs/fff.sys.qualiproj.access_log common
</VirtualHost>
#########END#########vodafone2631###################

now through a shell script i need to add mime type  for domain
vodafone.com, i would  need to add the following bellow "DoucmentRoot"

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

How can this be done ? would i need to know Perl scripting ..or can this be
done without the knowledge of Perl

Your help would be of great value !!
-- 
Regards
Agnello Dsouza
www.linux-vashi.blogspot.com

Re: [users@httpd] editing httpd.conf file through shell script

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 18.06.08 19:09, Agnello George wrote:
> i am trying to edit my httpd.comf file through a shell script ......      ((
> actually I trying to set up a control panel ))

> now through a shell script i need to add mime type  for domain
> vodafone.com, i would  need to add the following bellow "DoucmentRoot"

> AddType application/x-httpd-php .php
> 
> AddType application/x-httpd-php-source .phps

do you need to do that once?
Why don't you set that globally?

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
(R)etry, (A)bort, (C)ancer

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] editing httpd.conf file through shell script

Posted by Agnello George <ag...@gmail.com>.
On 6/18/08, Mohit Anchlia <mo...@gmail.com> wrote:
>
> You can use head and tail commands in shell to do what you want to do. You could do something like:
>
> x=`grep -n "DocumentRoot /websites/vodafone/web" httpd.conf` # gets the line number
> cat httpd.conf|head -$x > tmp.conf
> echo "AddType application/x-httpd-php .php" >> tmp.conf
> cat httpd.conf|tail +$x >> tmp.conf
> mv tmp.conf httpd.conf
>
> Above code is not tested. It's just for your understanding.

I was able to solve  my able query using sed command .. my script goes
some thing like that and its completely solve my problem

sed -i "/MIME_TYPE_$domain2631/a\AddType application x-httpd-php .php
\nAddType application x-httpd-php-source .phps"
/usr/local/apache2/conf/extra/httpd_vhost.conf

the a ---> stand for append after the given pattern

the \n ---> stand for add ""this"" to next line

But one thing still remain is how do i remove or reverse this procedure ... ??


-- 

सादर
Agnello Dsouza
www.linux-vashi.blogspot.com

Re: [users@httpd] editing httpd.conf file through shell script

Posted by Mohit Anchlia <mo...@gmail.com>.
You can use head and tail commands in shell to do what you want to do. You
could do something like:

x=`grep -n "DocumentRoot /websites/vodafone/web" httpd.conf` # gets the line
number
cat httpd.conf|head -$x > tmp.conf
echo "AddType application/x-httpd-php .php" >> tmp.conf
cat httpd.conf|tail +$x >> tmp.conf
mv tmp.conf httpd.conf

Above code is not tested. It's just for your understanding.



On 6/18/08, Agnello George <ag...@gmail.com> wrote:
>
>
> hi
>
> i am trying to edit my httpd.comf file through a shell script ......
> (( actually I trying to set up a control panel ))
>
> my httpd.conf host directives for many domains  , the file is  something
> like this :
>
>
> ##########START#######rodney.com###################
>
> <VirtualHost 192.168.0.244:80 <http://192.168.0.244/>>
> ServerAdmin admin@ashish.sys.qualiproj.com
> ServerName rodney.sys.qualiproj.qualispace.com
> ServerAlias www.rodney.sys.qualiproj.qualispace.com
> DocumentRoot /websites/rodney.com/web
> ErrorLog /websites/rodney.com/logs/rodney.sys.qualiproj.error_log
> CustomLog /websites/rodney.com/logs/rodney.sys.qualiproj.access_log common
> </VirtualHost>
> ##########END############rodney.com###################
>
>
> #########START#########vodafone###################
>
> <VirtualHost 192.168.0.244:80 <http://192.168.0.244/>>
> ServerAdmin admin@ashish.sys.qualiproj.com
> ServerName fff.sys.qualiproj.qualispace.com
> ServerAlias www.fff.sys.qualiproj.qualispace.com
> DocumentRoot /websites/vodafone/web
> ErrorLog /websites/vodafone/logs/fff.sys.qualiproj.error_log
> CustomLog /websites/vodafone/logs/fff.sys.qualiproj.access_log common
> </VirtualHost>
> #########END#########vodafone2631###################
>
> now through a shell script i need to add mime type  for domain
> vodafone.com , i would  need to add the following bellow "DoucmentRoot"
>
> AddType application/x-httpd-php .php
>
> AddType application/x-httpd-php-source .phps
>
> How can this be done ? would i need to know Perl scripting ..or can this be
> done without the knowledge of Perl
>
> Your help would be of great value !!
> --
> Regards
> Agnello Dsouza
> www.linux-vashi.blogspot.com
>
>

Re: [users@httpd] editing httpd.conf file through shell script

Posted by Krist van Besien <kr...@gmail.com>.
On Wed, Jun 18, 2008 at 15:39, Agnello George <ag...@gmail.com> wrote:

> now through a shell script i need to add mime type  for domain vodafone.com
> , i would  need to add the following bellow "DoucmentRoot"
>
> AddType application/x-httpd-php .php
>
> AddType application/x-httpd-php-source .phps
>
> How can this be done ? would i need to know Perl scripting ..or can this be
> done without the knowledge of Perl

This can be done with any scripting language capable of processing
text files (ie. most of them), and you will need to know the language
you choose to use for this. If you really want to build a control
panel that manipulates the httpd.conf you will have to learn how to
program.

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org