Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out, which user is running the current php script?

Tags:

php

apache

How do we determine which user the php script is running under when I run the script on server? Is it running under the same user as apache or phpmyadmin by chance? My question maybe wrongly framed but I want to know which user so that I set appropriate permission for different folders in /var

like image 457
Shagun Sodhani Avatar asked Jun 18 '12 17:06

Shagun Sodhani


People also ask

What user does PHP run as?

The user that runs apache/php is www-data . Run sudo chown -R www-data:www-data /var/www/deploy. log to make the file editable by the web server. The other files you want to perform operations on also need to be writable by the webserver.

How do I know if a PHP script is running?

In PHP this can be retrieved using getmypid() which will return an integer number. This pid number can be saved to a file and each time the script is run a check made to see if the file exists. If it is the posix_kill() function can be used to see if a process is running with that pid number.

Can users see PHP?

PHP is a server-side programming language, meaning it is executed at the web server before the website is sent to the end-user. This is why you can't see the PHP code when you view the source code.

What is Whoami PHP?

The PHP manual says that exec('whoami') returns "the username that owns the running php/httpd process" Link.


1 Answers

Execute whoami:

<?php echo exec('whoami'); ?>
like image 59
jpiasetz Avatar answered Oct 22 '22 14:10

jpiasetz