LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Programatically change AllowOverride for <Directory /var/www/> (https://www.linuxquestions.org/questions/linux-server-73/programatically-change-allowoverride-for-directory-var-www-776953/)

BassKozz 12-19-2009 06:37 PM

Programatically change AllowOverride for <Directory /var/www/>
 
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:
Code:

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:
Code:

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 / or /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.

ghostdog74 12-20-2009 06:00 PM

use an address,
Code:

sed '/<Directory \/var\/www\/>/s/.......' /etc/apache2/sites-enabled/000-default


All times are GMT -5. The time now is 04:21 AM.