Jump to content

php & SymLinks


webent

Recommended Posts

Question about php & SymLinks... I can make the symlinks in ssh as root, but how can perform that action in php?

 

for example, this is what I use in ssh terminal

cd /home/seconddomain/public_html/shoppingcart
ln -s /home/maindomain/public_html/shoppingcart/images images

 

So, from what I could tell, I would do this in php

$symlink_source = "/home/maindomain/public_html/shoppingcart/images";
$symlink_destination = "/home/seconddomain/public_html/shoppingcart/images";
exec("ln -s $symlink_source $symlink_destination");

 

But it does not work, I'm assuming its hitting a permission error, I'm running the script from the maindomain. Is there anyway for the script to be ran with root privledges or does anyone have an idea as to how to overcome this issue?

Link to comment
Share on other sites

Ok, thanks Thorpe... From what my server people told me, a non-root user cannot access public_html files, even if that user has multi-domain permissions, only root can, so how does one run php scripts that require root privledges?

Link to comment
Share on other sites

so how does one run php scripts that require root privledges?

 

You need to configure sudo to allow the apache process to execute the given command as root, this is however a very bad idea.

 

A better idea might be to give permission for the apache process to write to /home/*/public_html.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.