MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
February
Sun Mon Tue Wed Thu Fri Sat
   
11
         
2011
Months
Feb


Fri, Feb 11, 2011 9:12 pm

Whoami - How to determine the account under which PHP is running

If you need to determine the account under which PHP is running on a web server, you can use the code below:
<?php
  passthru("whoami");
?>

On a web server running Apache as the web server software, you can expect this to be the same as the account under which Apache is running, so you may see apache as the result. Or, if the system is using virtual hosts and suexec, e.g., with an SuexecUserGroup directive in Apache's httpd.conf file for the virtual host, then you may see the userid associated with the website listed.

If you wish to see the user ID, group ID, and groups for the account under which PHP is running, you can use the following code:

<?php
system("id -a");
?>

If PHP and Apache are running under the apache userid, you might see output similar to the following:

uid=48(apache) gid=48(apache) groups=48(apache)

Reference:

  1. How to find out what user PHP is running as
    Date: December 13, 2007
    PHP, MySQL and Affiliate Marketing Technology | davidmorison.com

[/languages/php] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo