homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Run php script as a different user

 6:54 pm on Oct 31, 2007 (gmt 0)

Hello, I am having trouble with one of my php scripts which needs to create/edit/delete different files within a website. The problem is when I upload the files via FTP they are all given a specifc "owner" and "group". However when the scripts are run by me browsing to them the scripts are run by "nobody" in which case it dosn't have the privllages to create/edit/delete files (or even chmod, or chown, the files). So is does anyone know how to run the script as a specific user?

Or maybe this can be set in the .htaccess file? Whenever abc.php runs it runs as "Someuser"?




 7:19 am on Nov 7, 2007 (gmt 0)

Don't think you can run php as a different user so you are going to have to change the permissions on download so that php can use the file.


 12:35 pm on Nov 7, 2007 (gmt 0)

if i understand correctly, while you are "nobody" you want to run a script from the command line terminal as "Someuser".
(also assuming *nix os here)

try this:
su - Someuser -c "whatever command"

unless you are "root"(-like) it will ask for Someuser's password.

you could also look into ssh to avoid the password.

if you are trying to run your php script under apache as a different user you can use suexec but beware of security issues when configuring and using this.


 12:45 pm on Nov 7, 2007 (gmt 0)

If your files dont have permission to write to other files then you may need to make these file you want written to available to the public. However this does present a security risk if you are allowing anyone to write to those files. You can use the CHMOD 666 (the devils work ;)), as this will allow anyone to read or write to the file.

I knew there was someone asking about 666 a while ago...Iv just checked and it was you, so I guess this isnt very helpful for you. Sorry

[edited by: PHP_Chimp at 12:48 pm (utc) on Nov. 7, 2007]

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved