• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

Nearly identical sites in Apache

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
sypder
Asked:
sypder
  • 7
  • 5
  • 2
  • +1
1 Solution
 
ozoCommented:
#!/bin/bash
for f in siteA/httpdocs/* ; do
  ln $f siteB/httpdocs/
done
0
 
TintinCommented:
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
 
sypderAuthor Commented:
Yes. Let's say I wanted the folders to be identical, except for one file.
0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
NopiusCommented:
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
 
sypderAuthor Commented:
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
 
ozoCommented:
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
 
TintinCommented:
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
 
sypderAuthor Commented:
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
 
TintinCommented:
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
 
sypderAuthor Commented:
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
 
TintinCommented:
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
 
sypderAuthor Commented:
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
 
sypderAuthor Commented:
Sorry I am doing such a bad job explaining this.
0
 
TintinCommented:
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
 
sypderAuthor Commented:
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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 7
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now