Symbolic link between user accounts

Craven

New member
Joined
Jul 19, 2009
Messages
3
I am working on creating a web application where multiple users would run off of one PHP codebase. The way this would work, in my head, is that I would have my primary codebase set up as a user on the system, and the files would be in the public_html (/home/codebase/domains/codebase.com/public_html/).

The next step would be for each client I sign up I would create a new user account and symlink to the codebase for each file and directory needed.
Example: A symlink set up as /home/client/domains/client.com/public_html/phpfile.php to /home/codebase/domains/codebase.com/public_html/phpfile.php.

This way each client would not be able to access configuration files for different users.

So I need to know a couple things to make this work:
  1. Would creating a symlink to another account be possible? I think there would need to be some setting changed so that php would have access to the other user (codebase) account.
  2. If point one is possible, then would there be a way to programmatically create the symlinks. Either through php or by using php to call a server script that accepts variables to create the symlinks?

Thank you in advance as I am having a lot of issues figuring out how to make this work and this so is the best option I can come up with.
 
Ok after doing some testing under my reseller account and after researching what I discovered in PHP's documentation I appear to have found an issue.

My host is using open_basedir, as such from what I understand about PHP symlinks would not work as they are resolved prior to being filtered through open_basedir.

As such I have one other possibility that I think may potentially work for my situation.

Would it be possible to add a specific path to open_basedir for specific user accounts? In my example I would need /home/codebase/domains/codebase.com/public_html/

Thanks again.
 
Here is how I share code between mutiple vhosts - maybe this will give you a few ideas:

For sake of something concrete, I will use "codebase.com" as the domain and "codebase" as the user which will host your code base. I would then create the directory

/home/codebase/domains/codebase.com/php

and add that to your include path. Then create custom templates (e.g. /usr/local/directadmin/templates/custom/virtual_host2.conf) that include the above in your open_basedir_path - e.g.

|?OPEN_BASEDIR_PATH=`HOME`/:/home/codebase/domains/codebase.com/php/:/usr/local/lib/php/|
...
php_admin_value open_basedir |OPEN_BASEDIR_PATH|​

Now ftp your code to codebase.com/php - if it is a volatile reusable like zend, you can be good to yourself and use symlinks here for versioning (i.e. put the upload in say Zend-1.7.8 and then create a 'Zend' symlink you use for all references). Now you can access your php repository from anywhere with a simple include (i.e. "require_once('Zend/Acl.php');" using my previous example).

I am very fussy and don't allow anything other than stubs above the document root of a vhost account (ala zend), so I use the parent directory of the vhost for vhost specific code, configuration, etc.

Hope that helps...
 
gaw,

Thank you for the information. I was starting down on the path that you just explained and found the information very helpful.

As I am by no means a DirectAdmin expert (currently a reseller, although my host is very helpful and accommodating), is there a way to apply a custom template to users created under a specific reseller? That way I would not have to submit a support ticket to have my host apply the custom open_basedir.

**As a note I am going to be switching to a dedicated server as soon as my client base supports it so I can do this on my own server down the road as a global template applied to all users created. But it would be really nice to have a one step system (creating the user) to set up a new client account.
 
Back
Top