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
https://forums.phpfreaks.com/topic/114703-php-symlinks/
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
https://forums.phpfreaks.com/topic/114703-php-symlinks/#findComment-590031
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.