Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 /var/www/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all

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

 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 ::1/128


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
up vote 3 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


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.