PHP script as user

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tiborv
Forum Newbie
Posts: 11
Joined: Wed May 11, 2005 1:11 am

PHP script as user

Post by tiborv »

How to run web PHPscript in specified user, not in apache(default).

In linux you create user test, and he has rights like root.
Now you want to run http://www.yoursite.com/test.php, and script test.php is a execute script.
But by default scripts are treated like user apache,but apache hasent got enough rights to do test.php demand , and now i want that script will be executed by user test, which has the root rights.

Thanks for answer !!
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Since Apache is invoking PHP to run the scripts, PHP *must* inherit the user rights of Apache. My guess is to increase the user rights for user Apache, although if you need *root* rights, you're probably looking in the wrong places.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

if you give your users root rights then its basically saying "please take down the server"

you may be able to set your server settings to allow this somehow but im sure everyone thinks its a real real bad idea
tiborv
Forum Newbie
Posts: 11
Joined: Wed May 11, 2005 1:11 am

Insane apache :)

Post by tiborv »

Changing Apache rights to Root is insane !
It was just an example :).
Yes i am going to increase Apache rights. What about .htacces ? Will it be god ?


Thanks !
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

which user and group it should run as is all in the .conf-file, however can be quite tricky as you aren't truly free.

a per directory-conf should not work I believe (would be rediculous having 100 apacheinstances running for the fact there are 100 folders all running using different users.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

suexec and suphp are the tools that you might want to look into..
tiborv
Forum Newbie
Posts: 11
Joined: Wed May 11, 2005 1:11 am

Post by tiborv »

Thanks for the answers !
Post Reply