Solved

Nearly identical sites in Apache

Posted on 2007-04-09
15
275 Views
Last Modified: 2010-08-05
I have two sites, which are virtually identical. I would like SiteB to be the same SiteA, except for a few specific files.

I would therefore like

siteB/httpdocs/* to be the same as siteA/httpdocs/* except when a particular file exists in siteB/httpdocs.

Does that make any sense?
0
Comment
Question by:sypder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18879195
#!/bin/bash
for f in siteA/httpdocs/* ; do
  ln $f siteB/httpdocs/
done
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18879269
ozo's solution was what I was thinking along the lines of.

In your document root, do you want the files to be identical at that level, apart from one specific file?
0
 
LVL 3

Author Comment

by:sypder
ID: 18879295
Yes. Let's say I wanted the folders to be identical, except for one file.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 27

Expert Comment

by:Nopius
ID: 18879299
sypder, not clear what do you want, share common files (then I agree with ozo) or keep everything in one directory while one site will have more files that another (that's also possible with creating two <VirtualHost> with the same DocumentRoot and one of these VirtualHosts may have <Files filename></Files> that restricts access with 'Order Allow,Deny'.
0
 
LVL 3

Author Comment

by:sypder
ID: 18879711
Let's say I have site A and B

Site A has the following files:

page1.php
page2.php
page3.php
/images/image1.jpg
/images/image2.jpg
/images/image3.jpg

Now I want site B to have all these same files, as may be accomplished with a ln -s. But I want to override:
page2.php
/images/image3.jpg

Imagine "ln -s all files which are not in /siteB/httpdocs"
0
 
LVL 84

Expert Comment

by:ozo
ID: 18879791
the ln example above would fail when page2.php already exists, so that should do what you want.
It would also fail when images/ is a directory, which is not what you want.
You could modify it to link recursively, either letting it fail when the file already exists,
or just link everything and then change the siteB/ files that you want to be different.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18879963
I don't know how many files you have in real life and how often you want to change them, but if you just link all files from Site A to Site B, then just unlink the specific files you want to change on site B and create a file for them.
0
 
LVL 3

Author Comment

by:sypder
ID: 18880171
Yeah, there are hundreds, and they are changing fairly often, so I was looking for an automated solution...

It may just not be possible.

Something like

if $file is not in SiteA get from SiteB.

Basically, I am designing a retail site and a wholesale site. They are on different domains, and only a few minor things, logos, pricing, etc, are different. But most of the PHP query functions, images, etc. are the same.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18880792
Your last comment appears to be different from what you originally stated.

Are you now saying that SiteA and SiteB will be identical, apart from SiteB potentially having some different files and if so, copying/linking them across to siteA?
0
 
LVL 3

Author Comment

by:sypder
ID: 18885514
Yeah, that is what I am trying to get.

Basically, SiteB is the same as SiteA except for a few files which SiteB will have.

So basically.

if ($file is in $SiteB)
  use $SiteB/$file
else
  use $SiteA/$file
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18885628
and in the instance where siteA has 'file1' and siteB has 'file1', which should be viewed?  The version on siteB?  If so, why have a different copy on siteA?
0
 
LVL 3

Author Comment

by:sypder
ID: 18885644
Okay:

Only siteA has a file: Both siteA and siteB serve that file
If both siteA and siteB has the file: siteA serves the siteA file, and siteB serves the siteB file
Only siteB has a file: Only siteB serves that file
0
 
LVL 3

Author Comment

by:sypder
ID: 18885647
Sorry I am doing such a bad job explaining this.
0
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 18885831
OK, in that instance, what i'd do is use rsync both ways to copy any file that exists on one site and not the other.

eg:

On SiteA, do

rsync -av --ignore-existing httpdocs /siteB/httpdocs

and vice versa on SiteB.

Obviously, this isn't going to be as efficient on space as using symbolic links, but given the nature and number of changes between the sites, it's probably the easiest way of handling it (unless someone else has a brainwave)
0
 
LVL 3

Author Comment

by:sypder
ID: 18960512
Okay... So I have thought about it, and here is what I would like to do.

in my httpdocs I have:

images
includes
pages

I would like to us a symbolic link to the old site.

Then I will have

newimages
newincludes
newpages

I would like an htaccess to first see if the new version exists.

So if you request /images/image.gif, the htaccess delivers /newimages/image.gif if it exists, otherwise just deliver /images/image.gif

Does that make sense?
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question