0

I'm writing a bash script which will eventually automate user configuration for Apache. I have this part of the apache configuration (httpd.conf):

NameVirtualHost X.X.X.X:80
<VirtualHost *:80>
  ServerName qa-market.local
  DocumentRoot /var/www/networks
  Alias /alex /var/www/networks/net-32
  Alias /daniel /var/www/networks/net-24
</VirtualHost>

I want the script to add another Alias directive within the <VirtualHost></VirtualHost> section and after the last Alias line. That's the directive I want the script to add:

Alias /\$user /var/www/networks/\$userdir

How can it be done? Thanks!

1
user=foo
userdir=bar
sed "/<\/VirtualHost>/i\  Alias /$user /var/www/networks/$userdir" filename
  • The $user and $userdir are variables.. I want their value inserted in the path directive instead of "$var" , how is it done please? – Itai Ganot Jul 27 '14 at 12:10
  • I've updated my answer. – Cyrus Jul 27 '14 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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