This is similar to questions that have been asked before, but I promise it is different.
I have a site that involves inheritance from a parent to a child site. Part of this is media. To make media serve faster, I am creating a symlink-ed copy of the parent directory in the child, then override those with any files the child specifically defines. This allows apache to serve statically from the media (which may come from a parent) while inheriting html form the parent.
Example after build where inheritance is common->maps->cars :
/some/directory/common/
images/
cats.png
muffins.png
css/
styles.css
/some/directory/maps/
images/
cats.png -> /some/directory/common/images/cats.png
muffins.png (overridden by child)
css/
styles.css -> /some/directory/common/css/styles.css
mapsStyles.css (child only)
/some/directory/cars/
images/
cats.png -> /some/directory/common/images/cats.png
muffins.png -> /some/directory/maps/images/muffins.png
css/
styles.css -> /some/directory/common/css/styles.css
carsStyles.css (child only)
So I could symlink to /images/muffins.png
and receive the correct media based on the site that I'm on. The site-specific media is stored in the same directory structure, but in a different location only containing media specific to that site.
The issue is that no matter how I try to do it, the second child ends up with a symlink to its parent, not the originator. In the example above, I cannot get /some/direcory/cars/images/cats.png
to point to the common media programatically, only the maps media.
Currently I am using the command cp -sR /some/directory/maps/* /some/directory/cars/
I'm running this on PHP, but currently using cp
and ln
commands in the PHP exec()
function to build these structures.