0

I have a Virtual Private server with Dreamhost. I'm trying to create a shared folder that all of my domains can access. In the folder I'd like to put PHP classes, and even static files like javascripts.

I've created a directory on the same level as my domain folders. I'd like to call a file via something like this... /home/username/shared/file.php. This isn't working however for static files, and I'm hoping some magic (like .htaccess maybe) will make this work.

This works:

<?php include('/home/username/shared/file.php'); ?>

This doesn't work:

<link rel="stylesheet" type="text/css" href="/home/username/shared/reset.css" media="screen" />

Alternatively, I realize that I could just place my static files inside of a domain, and simply point to them, but I'd like to know how to make this other configuration work.

2 Answers 2

0

You will never be able to include a server path-based file in an HTML file like that because the path is outside of the scope of public_html.

I know what you're trying to do, but I honestly don't think it's easily accomplishable. Why not just set up a subdomain on a 'master' domain from which all domains source the files? Less desirable perhaps if you're going for the perfect SEO (because I believe it's technically classed as cross-domain referencing) but having certain globally-required files (images etc) on files.primarydomain.tld works very nicely for me.

Also given the way Dreamhost handles different users' files, it can be a real pain. Probably best with their setup to just set up one username with one subdomain and have it handle just the global files, particularly as if you have one username per site, that username won't have filesystem permissions to access files held in another username's directory. (and .htaccess-mod-rewrite based rules will just be digging a hole for yourself, even if it is possible!)

2
  • Also, I guess if I put them on a service like Amazon S3 / Cloudfront it would essentially accomplish the same thing plus give me the benefits of a CDN. The main reason why I asked was because I am coming from a LAMP environment with Coldfusion, and I was able to perform the above methods to get to static files. Then again, these were Private Servers (not through Dreamhost), not Virtual Private Servers. Thanks for the input.
    – mikemick
    Oct 7, 2010 at 16:08
  • Yeah, S3/Cloudfront is probably more desirable for what you're trying to achieve - having gone through many hours of pain trying to wrestle this setup out of Dreamhost, and failing dismally, I hope nobody else has to put themselves through the same pain! Dreamhost really is bloody annoying, you can have files in /public_html/subfolder/ uploaded by two usernames - and of course, in true Unix style, one username can't see the other files (nor can it serve them in public). UNIXy behaviour is great except when it gets in the way ¬_¬ It's impossible to reassign ownership too, really frustrating. Oct 18, 2010 at 14:29
0

Use a Symbolic Link (symlink).

I originally asked this question on StackOverflow (I didn't know about this site yet), and it has now been answered. The answer and explanantion can be found HERE

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .