Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I share files between vhosts?

Status
Not open for further replies.

danielrc15

Programmer
Sep 18, 2003
6
GB
Hi,

I have a vhosts set up, of several domains each in their own vhost.

What I need to do is share my php scripts across the vhosts, as I don't want to have to create copies of the files and store them in each vhost.

I want to share my db config and php function scripts across vhosts.

So have them situated above the vhost area, so they are not accessible via a url, I have tried to place them outside the vhost documentroot and access the files in php, but it does not work.

How can I share files across virtual hosts?

Thanks

Daniel
 
My experience has been that you can symlink an external folder into a hierarchy under a vhost's webroot.

Consider:

/home/sources/masterconfigs/vhosts_category_A/[files.php]

/home/apache/vhosts/www.example.com/html/[website files]
/home/apache/vhosts/www.example.net/html/[website files]

You SHOULD be able to go to ../ and issue
Code:
ln -s /home/sources/masterconfigs/vhosts_category_A config_files

You'll need to check your permissions, but what you should end up with is a symlink folder called

/home/apache/vhosts/
Which should be immediately web server accessible.

Repeat this for each suitable vhost and you now have a common folder that is included in each vhosts "site".

Keep in mind that symlinking folders in from outside the webroot is a questionable security practice, and folder ownership will require a little work.

Thus, you can accidentally INCREASE your security risk profile through being careless in performing this.






D.E.R. Management - IT Project Management Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top