The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Execute PHP as a the User

Discussion in 'General Discussion' started by shaun, Mar 26, 2002.

  1. shaun

    shaun Well-Known Member

    Joined:
    Nov 9, 2001
    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    San Clemente, Ca
    Have a client who wants to execute php with his UID/GID anybody have info on how to do this. Also Nick do you plan on having php execute as the user in the future.
     
  2. Brownie

    Brownie Well-Known Member

    Joined:
    Aug 10, 2001
    Messages:
    145
    Likes Received:
    0
    Trophy Points:
    16
    If you've got SuEXEC installed, just chmod the file to 755 and put a shebang at the top - should run PHP as that user :)

    #!/usr/bin/php
    &?php
    .......
     
  3. shaun

    shaun Well-Known Member

    Joined:
    Nov 9, 2001
    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    San Clemente, Ca
    well the reason for running the script as the user is so that the script cannot be read by others mainly. 0750 should work if 0755 does... I hope, i'll try this out. Thanks.

    reason for 0750 is so that people cannot read a php file that has passwords in it for the people wondering.
     
  4. gordita

    gordita Well-Known Member

    Joined:
    Aug 14, 2001
    Messages:
    113
    Likes Received:
    0
    Trophy Points:
    16
    yes, running PHP as a CGI script would allow the script to be run under the users uid/guid since you are using SuExec, but if you want to run mod_php (or mod_perl) scripts under a specific UID/GID your best (only) plan is to create a seperate httpd instance for this user - this provides the strictest security although it does require some manual configuration and you probably don't want to create a ton of these individual user specific httpd processes.
     
Loading...

Share This Page