PDA

View Full Version : running php scripts as a cgi?


Czervik
03-14-2004, 01:59 AM
I'm not sure if this should go in the php forum or here. I'm trying to change folder ownerships, and the support guy at HostRocket says it can only be done using a cgi script:

"Only the root user can use chown commands. You would need to run your php scripts as a cgi if you wanted them to run as your username. Check php.net for help with this."

I've checked php.net but couldn't find anything. I've never used cgi, so I'm not sure what to do. Could someone please give me a few pointers to get started?

Thanks

Cope
03-14-2004, 02:35 AM
Yeah. Its kind of hard to chmod a file that 'www' users dont have rights to. I understand what you are asking for but I have yet to find it. I never wanted to do anything like this, so never even thought of it... I will continue to look for a solution.

HRGraham
03-14-2004, 11:07 AM
PHP runs as the user "nobody", so any file you create through a PHP script will be owned by the user nobody. This will prevent you from removing or modifying the file while logged into your account. You will only be able to modify the file through a PHP script.

We have SuExec installed on the server, which means Perl(CGI) scripts run as your user, not the nobody user. This means that whenever you create a file through a Perl script, it will be owned by your user.

Hope this cleared things up.

-Graham

Czervik
03-14-2004, 02:46 PM
Originally posted by HRGraham
PHP runs as the user "nobody", so any file you create through a PHP script will be owned by the user nobody. This will prevent you from removing or modifying the file while logged into your account. You will only be able to modify the file through a PHP script.

That's exactly my problem. I'm writing the scripts for a friend who's not familiar with PHP, so I want him to still have access through an ftp client or the HR control panel.


We have SuExec installed on the server, which means Perl(CGI) scripts run as your user, not the nobody user. This means that whenever you create a file through a Perl script, it will be owned by your user.

Hope this cleared things up.

-Graham

So, if I create a folder that's owned by my username, will it still be able to upload a file via PHP? I probably have to run the upload script as CGI also, right?

Is this where I need to use the suexec() function? My co-worker showed me it when I asked him for help, but it seems like we didn't get anywhere with it.

Thanks for the help,
Chris

HRGraham
03-14-2004, 04:01 PM
So, if I create a folder that's owned by my username, will it still be able to upload a file via PHP? I probably have to run the upload script as CGI also, right?


Yes, you can still write to it from a php script if the directory you are writing to has write permissions.

Is this where I need to use the suexec() function? My co-worker showed me it when I asked him for help, but it seems like we didn't get anywhere with it.

Thanks for the help,
Chris

You don't have to do anything special to run it under suexec. All Perl/CGI scripts are run under suexec.

Czervik
03-14-2004, 06:03 PM
So what do I need to know about Perl/CGI to get started?