June 30th, 2000, 06:01 AM
I wish to automate certain administrative tasks on my dedicated Linux server with PHP. However, it would be necessary that my script is running with the privileges of the root and it is not advised to launch Apache under the root user. How can I change the current user in my PHP script?
Thank you for your lights.
June 30th, 2000, 05:40 PM
Read up on suexec in the PHP manual.
June 30th, 2000, 06:49 PM
I sought "suexec" on php.net and zend.com and I did not find anything. Are you sure this command exists?
[This message has been edited by manu02 (edited June 30, 2000).]
I am not sure if this is on the same subject or not but I am trying to make a filemanger script and I want to be able to have the PHP script be able to delete/create/modify files.
As of now I can't do the actions because when ever my script makes an attempt I get a permission denied because the script is like a general web surfer. I could fix this be giving write permissions to every file/directory but I REALLY don't want to do this.
Is there a way to make the script so it is like the owner of the files and has the same permissions as I do?
[This message has been edited by Aoeex (edited July 01, 2000).]
Before posting my question, I made a search in many forums (Zend, DevShed, PHPBuilder, PHP Club Forums...). Many people ask the same thing: how to change the privileges of a PHP script without modifying the Apache configuration. No solution was found, then, is this impossible? Is there Linux/PHP gurus in the room?
I did find some stuff on that suexec and it sounds about like what I want but I am not too sure how to use it. If somebody could explain it better to me I might figure it out sooner or later. I don't know much about apache or linux so I would need a lot of explaining done. the informaation I found is at
>>I don't know much about apache or linux so I would need a lot of explaining done.
>.Is there Linux/PHP gurus in the room?
This has less to do with Apache and PHP and it's not just for linux, it's so called "Unix Basics about Permissions".
Let say you run Apache as nobody and nogroup,
let say the user "bob" and his file -> /home/bob/public_html/somefile.ext, do "ls -Al", it would show something like this ->
-rw-r--r-- 1 bob bob 313 June 23 21:25 somefile.ext
then, somefile.ext is readable by All including "nobody" but not writable or executable. If you chmod it to 664 (-rw-rw-r--), then it's still writable and by "bob" since nobody else is in "bob" group. Let say you chmod it to 646 (-rw-r--rw-), then it's writable by "nobody". If you chmod it to 745 (-rwx-r--r-x), then it's executable (but not writable) by "nobody".
>>How can I change the current user in my PHP script?
manu02, with all the permisson stuffs being said, you have a few alternatives:
1) Recompile your PHP as CGI, not as a module of Apache, then run from command line as root
2) Or convert your PHP to Perl and run from command line as root
3) Run Apache as 'root'
Aoeex, suEXEC is what you needed, or else, you need to chmod your files to appropriate permission so "nobody" can 'r' or 'w' or 'x' it. With suexec, let say it's a Perl script, its permission could be as low as "-rwx------" (700).
[This message has been edited by freebsd (edited July 02, 2000).]