Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I progamatically (using BASH) change AllowOverride for <Directory /var/www/> from 'None' to 'All' ?

Rather then having to manually edit /etc/apache2/sites-enabled/000-default

Normally I could just use sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/sites-enabled/000-default

However my 000-default file has other AllowOverride directives that I don't want to change:

NameVirtualHost *
<VirtualHost *>
 ServerAdmin webmaster@localhost

 DocumentRoot /var/www/
 <Directory />
  Options FollowSymLinks
  AllowOverride None
 </Directory>
 <Directory /var/www/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
 </Directory>

 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 <Directory "/usr/lib/cgi-bin">
  AllowOverride None
  Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  Order allow,deny
  Allow from all
 </Directory>

 ErrorLog /var/log/apache2/error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog /var/log/apache2/access.log combined
 ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

For example I don't want AllowOverride on /usr/share/doc or /usr/lib/cgi-bin

I just want it set on <Directory /var/www/> p.s. I am on Ubuntu-Server 8.04.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

To change from None to All:

awk '/<Directory \/var\/www\/>/,/AllowOverride None/{sub("None", "All",$0)}{print}'
share|improve this answer
    
Thanks Dennis, That did the trick :) –  BassKozz Dec 20 '09 at 18:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.