1

I'm trying to consolidate some website files on one of our CenotOS servers, the setup i want to create is something like this but i'm not sure if its actually possible

we would have a set of files used by all sites:

/home/commonfiles/
                 public_html/
                 library/

each site directory would look something like this:

/home/site1/bespoke/
                   css/
                   images/ 

each "site" would use the public_html and library folders from within the common files. Symlinks would obviously work for this. What i would also want though is for /home/commonfiles/public_html/css to point to /home/site1/bespoke/css where site1 is the site that the absolute link to /home/commonfiles/public_html/ is from. I know its possible to create relative symlinks but is it possible for an absolute symlink to contain a relative one.

I hope this makes sense as i'd really appreciate some advice

EDIT

to elaborate, this is the basic structure i would want (if its possible)

/home/common
/home/common/public
/home/common/library
/home/site1
/home/site1/public -> /home/common/public
/home/site1/library -> /home/common/library
/home/site1/bespoke/
/home/site1/bespoke/css
/home/site1/bespoke/images
/home/site1/public/css -> /home/site1/bespoke/css 
/home/site1/public/images -> /home/site1/bespoke/images
/home/site2
/home/site2/public -> /home/common/public
/home/site2/library -> /home/common/library
/home/site2/bespoke/
/home/site2/bespoke/css
/home/site2/bespoke/images
/home/site2/public/css -> /home/site2/bespoke/css
/home/site2/public/images -> /home/site2/bespoke/images

I guess essentially the mapping of - for example - /home/site1/public/css -> /home/site1/bespoke/css does not necessarily have to be done with links, maybe this could be done in the .htaccess in some way. Hopefully you can see what i'm trying to achieve here though.

just to add to this, this is essentially what i'd like to be able to do (if it worked):

mkdir test
mkdir test/common
mkdir test/common/public
mkdir test/common/library
mkdir test/site1
mkdir test/site2
mkdir test/site1/bespoke
mkdir test/site2/bespoke
mkdir test/site1/bespoke/css
mkdir test/site1/bespoke/images
mkdir test/site2/bespoke/css
mkdir test/site2/bespoke/images
ln -s /home/user/test/common/public test/site1/public
ln -s /home/user/test/common/library test/site1/library
ln -s /home/user/test/common/public test/site2/public
ln -s /home/user/test/common/library test/site2/library
cd test/common/public
ln -s ../bespoke/css css
ln -s ../bespoke/images images
robjmills
  • 990
  • 9
  • 26

3 Answers3

1

It's not possible with links

Daniel
  • 1,713
  • 1
  • 12
  • 16
  • do you know of another solution? – robjmills Nov 13 '09 at 16:02
  • you can use redirects. For example something like this should work: RewriteEngine On RewriteRule ^public/css/(.*)$ bespoke/css/$1 [L,R=303] You have to fix the paths though and you need one in each virtualhost. – Daniel Nov 13 '09 at 19:08
0

The answer is yes. The test below is probably too tangled for what you want to do, but it may help illustrate what can be done.

$ mkdir test
$ mkdir test/a
$ mkdir test/a/dir1
$ touch test/a/dir1/file1
$ ln -s /absolute/path/to/test/a test/b
$ ls -l test
drwxr-xr-x 3 user user 4096 2009-11-13 07:45 a
lrwxrwxrwx 1 user user   28 2009-11-13 07:45 b -> /absolute/path/to/test/a
$ ls -l test/b
drwxr-xr-x 3 user user 4096 2009-11-13 07:45 dir1
$ cd b
$ ln -s ../a/dir1 dir2
$ ls -l
drwxr-xr-x 3 user user 4096 2009-11-13 07:45 dir1
drwxr-xr-x 3 user user 4096 2009-11-13 07:45 dir2 -> ../a/dir1
$ ls -l dir1
drwxr-xr-x 3 user user 4096 2009-11-13 07:45 file1
$ ls -lH dir2
drwxr-xr-x 3 user user 4096 2009-11-13 07:45 file1
$ cd ../a
$ ls -l
drwxr-xr-x 3 user user 4096 2009-11-13 07:45 dir1
drwxr-xr-x 3 user user 4096 2009-11-13 07:45 dir2 -> ../a/dir1

That last entry is kind of interesting. It's essentially /absolute/path/to/test/a/../a/dir1.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
0

I do this with the multiple Wordpress installs on one of my web servers.

I setup the 'wp-content' directory (which has themes and plugins) to be shared amongst installs thusly:

/var/<site>/wp-content -> /home/common/wp-content
/var/<site2>/wp-content -> /home/common/wp-content
etc...

This would be done:

cd /var/<site>
ln -s wp-content /home/common/wp-content

I have perms on my /home/common/wp-content directory set to rwxrwxrwx on this particular device.

warren
  • 18,369
  • 23
  • 84
  • 135