Solved

Nearly identical sites in Apache

Posted on 2007-04-09
15
251 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
  • 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
 
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

New My Cloud Pro Series - organize everything!

With space to keep virtually everything, the My Cloud Pro Series offers your team the network storage to edit, save and share production files from anywhere with an internet connection. Compatible with both Mac and PC, you're able to protect your content regardless of OS.

Question has a verified solution.

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

Suggested Solutions

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

919 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now