Symlink from one user to another

Silvan

Verified User
Joined
Aug 29, 2012
Messages
29
I think it's a simple question, just not getting there. I want to create a simple symlink between users. Something like this:

ln -s /home/username1/domains/plugins/mypluginfolder /home/username2/domains/mydomain2.nl/public_html/plugins/mypluginfolder2

I think i'm stuck with permissions between two users. Also no problem to move the folder outside the other user. But need the symlink folder working on all accounts on the server. How to set this up properly?
 
That will work only if:

1. PHP is in mod_php mode, which means that your users will run with the same user (apache) and group.

OR

2. You must set the folder and the files of the shared resource as 777 (which is security risk and it will not work with SUphp because it won't allow it).

I don't know if you are using fcgi, frm or suphp, but in all those cases, including mod_php with mod_ruid2 (!), different users scripts will run with different owner and group. This is an important protection for shared hosting servers because that way one user can't touch the files of another (eg. something that you are actually trying to do) :)
 
Last edited:
P.S. One other way to set that up is to make both domains to be under the same user. That way their scripts will run with the same user.
 
Hi Wattie,

Thanks for your fast reply.

Few questions;
1. mod_php is there. And I did:

chown -R apache:apache /home/username1/domains/plugins/mypluginfolder
AND
chmod -R 777 /home/username1/domains/plugins/mypluginfolder


2. See above even did the 777 to try..


but still not working? The right way? Or am i missing something?

Thanks in advance,
 
Don't do chmod 777. Use the the lowest permissions possible that suits your needs.

Are both domains on mod_php? It could be an open_basedir restriction in effect... I am unsure.
 
I'm not sure about mod_php ? I see it as a module in php_info. But where can i check that? Maybe that's the problem. Its a normal directadmin install.

Edit, its open_basedir: get this error in apache logs: open_basedir restriction in effect "...... is not within the allowed path(s): (/home/user2/:/tmp:/var/tmp:/usr/local/lib/php/"

FIXXED:
Disabling open_basedir in PHP ini or HTTPD didn't work out strange enough. But disabled it on the PHP configuration on directadmin. Now it's working fine!


Thanks for your answers wattie, it helped me a lot !
 
Last edited:
Hello,

I think it's a simple question, just not getting there. I want to create a simple symlink between users. Something like this:

ln -s /home/username1/domains/plugins/mypluginfolder /home/username2/domains/mydomain2.nl/public_html/plugins/mypluginfolder2

If you don't need to allow your users to write to the folder, I'd rather suggest that you put your code into /home/admin/shared/ and use mount -o bind to bind the folder into user's public_html or /usr/local/php56/lib/php/shared/ (adjust your php version here) and include it from there. Yes it might be more complicated for understanding and setting up, but it gives you more security on the server, even if you are the only one user to host sites on the server.
 
Back
Top