Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > General

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 5th February 2010, 20:54
bigger_travis bigger_travis is offline
Junior Member
Join Date: Oct 2005
Location: us
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default chown not working with exec()

hello, i have ispconfig 2 running on Centos -

what i'm trying to do:
i am running a php file which installs a script in the web/ directory to install my custom script, the php file renames the web directory

from: /var/www/web2/web
to: /var/www/web2/web_Orginal

then the the php file creates a web directory:


so when i go to the shell i send the ls command and i can confirm both directories are there, so the script is able to rename the orginal web/ directory and create a new web/ directory (I am using tar to unpack the web/ directory which contains all my script files)


however, the new web/ directory is own by apache:

command: ls -la

drwxrwxrwx  8 apache   apache 4096 Feb  4 05:16 web
drwxrwxrwx  8 web2_AnyUser  web2 4096 Feb  4 05:16 web_Orginal
now i try to use exec() function in the php file to change the ower from apache to web2_AnyUser and the group from apache to web2 using this code in the php file:

PHP Code:
exec('chown -R web2_AnyUser /var/www/web2/web',$ouput,$result);
exec('chgrp -R web2 /var/www/web2/web',$ouput,$result);

i dont get any errors, and the value of $result = 1

so when i go to the shell, i do an ls -la and it does not change the owership of the web/ directory, it still shows apache

what i want to acheive is to change the owershipt to look like this:

command: ls -la

drwxrwxrwx  8 web2_AnyUser  web2 4096 Feb  4 05:16 web
drwxrwxrwx  8 web2_AnyUser  web2 4096 Feb  4 05:16 web_Orginal
do you have any suggestions. i think you are my best resource for this. i was looking at your code in /root/ispconfig/scripts/lib/config.lib.php and it shows this code on line 690:

PHP Code:
//exec("usermod -G web".$web_doc_id." ".$user_username."");
    // alten admin herausfinden
$old_admin_uid fileowner($web_path);
exec("chown $user_username $web_path &> /dev/null");
//exec("chown $user_username $web_path/cgi-bin &> /dev/null");
exec("chown -R --from=$old_admin_uid $user_username $web_path/cgi-bin &> /dev/null");
exec("chown $user_username $web_path/log &> /dev/null");
exec("chown $user_username $web_path/ssl &> /dev/null");
exec("chown $user_username $web_path/user &> /dev/null");
//exec("chown $user_username $web_path/web &> /dev/null");
exec("chown -R --from=$old_admin_uid $user_username $web_path/web &> /dev/null");

i guess im trying to do the same, but im not sure how you did it.

if you have any suggestion, please advise,

Thanks for all your support
Free Wallpapers - Wallpaper Website Server. Trying to get my server
Reply With Quote
Sponsored Links


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
exec not working DUCKFACE Developers' Forum 26 19th July 2012 10:16
Restoring permissions of /var/www after wrong chmod shrek Tips/Tricks/Mods 2 1st June 2009 22:15
Unable to install ISPConfig bdonecker Installation/Configuration 21 26th May 2009 09:20
fail2ban not working linuxwannabe Installation/Configuration 1 25th January 2009 07:09
DNS stop working MZH General 3 22nd February 2008 12:10

All times are GMT +2. The time now is 15:50.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.