Search code examples
phpapachedebianwebminphp-include

Share folders/files between two users (websites) on same server


I have dedicated server and a few websites on it, but I need to allow PHP to use/include files between two sites.

For example, the first website has file on this location /home/first/public_html/lib/mainclass.php

I need to include that file on the second website (/home/second/) in some file like this:

<?php
include('/home/first/public_html/lib/mainclass.php');

What exactly I need to do for that? Server is on Debian, and I have Virtulamin/Webmin—so it will be good if I can do that within. Tnx


Solution

  • Assuming that you are talking about library files that you share now between 2 but in the future between perhaps more sites, I would put them in the php default include_path (for example /php/includes) or a sub-directory of that.

    Or add a new directory outside of the individual user's home directories to store the library files and add that to the php include_path.

    That way they are always accessible to all sites on that server and they can only be modified by someone who has access to that directory.