bash script editing my apache config files

Tags
apache config, apache2, convenience, dropbox, web

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 06-30-2009
Lightbulb bash script editing my apache config files

okay i'm going to try to say this uber-simple:

I use dropbox (file-sync service). in order for dropbox sync files, they must be its children [eg. somewhere under /home/jzacsh/Dropbox].
I want to now use it to keep my development files in sync across my machines:
easy: just move my dev. files under dropbox
catch:I want them to still be viewed as the localhost docs by the server. (fyi: running apache on macbook and linux desktop).

I wrote the below alias into my shell's login file (.bashrc on my linux machine, .profile on my mac)
sidenote: maybe someone can tell me "for this much stuff - avoid aliases, you should be making them functions!"??? idk, it just looks messy I think [eg. servvar and servtmp aliases].

My solution
I placed these in my login script:
Code:
#apache's config file determining localhost's location on fs
serverConfig='/etc/apache2/sites-available/default'

#aliases to cd into, and to turn localhost location on
alias web='cd /var/www;clear; pwd; ls -la;'
alias servvar="sed -i 4,5s/#//g $serverConfig; sed -i 5s/^/#/g $serverConfig;sed -i 10,11s/#//g $serverConfig; sed -i 11s/^/#/g $serverConfig"

#aliases to cd into, and to turn localhost location on
alias tempdev='cd ~/Dropbox/crossPlatform/tempDev;clear; pwd; ls -la;'
alias servtmp="sed -i 4,5s/#//g $serverConfig; sed -i 4s/^/#/g $serverConfig; sed -i 10,11s/#//g $serverConfig; sed -i 10s/^/#/g $serverConfig"

this is a snippet (lines 4-11) from the config file set as $serverConfig just above^
Code:
4        #DocumentRoot /var/www
5         DocumentRoot /home/jzacsh/Dropbox/crossPlatform/tempDev
6         <Directory />
7                 Options FollowSymLinks
8                 AllowOverride None
9         </Directory>
10        #<Directory /var/www/>
11        <Directory /home/jzacsh/Dropbox/crossPlatform/tempDev>

upon logging in, if I tried to run either "servtmp" or "servvar" I would get a permission denied error (understandably).

on a complete guess I did this (after making an "original-*" copy of the config file)
Code:
chown jzacsh /etc/apache2/sites-available/default

idea was: in hopes it would give my login script proper permissions
that ^ resulted still in a "permissions" error, but even weirder looking
Code:
sed: couldn't open temporary file /etc/apache2/sites-available//sedPQrEht: Permission denied
sed: couldn't open temporary file /etc/apache2/sites-available//sedep6tEr: Permission denied
sed: couldn't open temporary file /etc/apache2/sites-available//sed2puLjs: Permission denied
sed: couldn't open temporary file /etc/apache2/sites-available//sedH5hTQv: Permission denied

I checked, and those funky temporary files weren't there when I looked (looked using ls -la)

okey-dokey, that's it, any help would be GREATLY appreciated, i know this is a bit of a funky request.
# 2  
Old 06-30-2009
This doesn't answer your 'My Solution' question, but I do something similar on a development machine. I use subversion to checkout from my code repository into /home/me/svn/site and create a symbolic link for apache to this location:
Code:
rm -rf /var/www && ln -s /var/www /home/me/svn/site

I know it doesn't answer your real question, but maybe this solution is easier. *shrug*
# 3  
Old 07-05-2009
Question anyone fairly experienced with Apache??? Document Root Fiddling?

Quote:
Originally Posted by glen.barber
This doesn't answer your 'My Solution' question, but I do something similar on a development machine. I use subversion to checkout from my code repository into /home/me/svn/site and create a symbolic link for apache to this location:
Code:
rm -rf /var/www && ln -s /var/www /home/me/svn/site

I actually considered using a link. I don't know why, but I just assumed that apache wouldn't play well with a link.

Quote:
Originally Posted by glen.barber
I know it doesn't answer your real question, but maybe this solution is easier. *shrug*
Well, this could be a work around. The only problem/reason its a work around and not a solution is because I actually have 24 GB of data inside my development folders on a couple computers. such a large development folder brings about two problems here:
  1. my dropbox account doesn't have that much of storage (nor would I want it syncing that stuff anyway)
  2. whenever running my login's "switch-server's-location" script, it would have to move the 24 GB of stuff out of /var/www just for the link to work.
I'll probably use link to redirect Apache just on a computer or two right now, but I'll still be searching for a more thorough solution. Thanks again, glen.barber, I appreciate the input.

Perhaps someone with a better understanding of Apache than me could explain to me "Apache's http root isn't meant to be fiddled with"? and such an undertaking isn't for the inexperienced?
Login to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Config xcache apache mnnn Web Programming 0 07-10-2016 03:43 PM
Parsing and Editing a json file with bash script Junaid Subhani Shell Programming and Scripting 5 04-20-2016 04:36 PM
Bash script deleting my files, and editing files in subdirectories question TheGreatGizmo Shell Programming and Scripting 4 02-05-2014 07:37 PM
Bash script to copy apache log files to client directory gregraven Shell Programming and Scripting 3 09-06-2013 01:58 PM
Apache virtual host config vs global config problem freebird8z Red Hat 1 04-05-2013 11:33 AM
bash script config file sadosan83 Shell Programming and Scripting 1 12-29-2011 06:38 PM
Problems editing file with awk in bash script sr00t Shell Programming and Scripting 5 03-04-2011 11:57 AM
Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report muraliinfy04 Shell Programming and Scripting 4 11-04-2010 08:30 AM
Editing lists of integers in 1d files with bash shell ac130pilot Shell Programming and Scripting 1 02-11-2010 11:27 AM
Script for editing column files JunZ Shell Programming and Scripting 2 03-25-2009 04:35 AM
editing files with script Asteroid Solaris 5 02-10-2009 11:20 AM
Editing MySQL config through ssh ? Denis.R UNIX for Advanced & Expert Users 2 02-15-2005 06:35 PM
Apache Config l008com UNIX for Dummies Questions & Answers 2 07-23-2002 06:54 PM
Apache Config Files Webwitch UNIX for Dummies Questions & Answers 1 08-01-2001 04:35 PM
All times are GMT -4. The time now is 03:40 AM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?