Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to show apache-php processes that runs on my server and on what account that process belong to. Basically I want top to display something like this:
Code:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
20686 user1 17 0 115m 18m 6444 R 56.2 0.2 0:01.69 php
20681 user1 17 0 116m 18m 6444 R 53.9 0.2 0:01.62 php
20574 user2 21 0 117m 21m 6444 R 43.3 0.3 0:04.74 php
20620 user2 19 0 118m 21m 6444 R 37.9 0.3 0:04.83 php
20636 user1 19 0 116m 19m 6444 R 34.3 0.2 0:03.46 php
instead of only showing 'nobody' that runs httpd like this
Code:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
18868 nobody 16 0 403m 58m 4248 S 8.0 1.5 0:05.31 httpd
12975 nobody 15 0 422m 74m 5940 S 6.0 1.9 0:20.27 httpd
13753 nobody 15 0 420m 72m 5828 S 4.0 1.9 0:26.25 httpd
12215 nobody 15 0 420m 71m 5900 S 2.0 1.8 0:22.88 httpd
21894 nobody 15 0 488m 91m 8084 S 2.0 2.4 1:39.80 httpd
I know it's possible for I took those two 'TOP' result as is from two separate machines that we have. Anyone has any idea how can I make it happens?
did you check the toprc files? Ie check for /etc/toprc on each machine and possibly the users toprc.
Also you should probably compare the version of top on each machine.
The result was Obvious:
in the machine that php username enabled, I can see the user and processes.
But for machine that displays 'nobody' only; nobody is the only thing I can get....
Again, it's not about the 'top' command, but something in php and/or apache setting that make each process be user specific...
The result was Obvious:
in the machine that php username enabled, I can see the user and processes.
But for machine that displays 'nobody' only; nobody is the only thing I can get....
Again, it's not about the 'top' command, but something in php and/or apache setting that make each process be user specific...
you can use system function in php and give the top command.
If I am not getting correctly , explain what actually you want .if possible paste ur php script
If these are php processes that are run as part of/by Apache (eg using mod-php), then of course they will run as the Apache user eg httpd, nobody, www ... whatever Apache runs as.
If you want to know who the 'user' is, you'd have to implement a login system/webpage and record the username in the program and then log the username + pid from the php program.
If these are php processes that are run as part of/by Apache (eg using mod-php), then of course they will run as the Apache user eg httpd, nobody, www ... whatever Apache runs as.
If you want to know who the 'user' is, you'd have to implement a login system/webpage and record the username in the program and then log the username + pid from the php program.
@Chrism01: thanks for your reply. I don't quite know how to do that though. Is that means that I can see user names using 'TOP' command?
For what I'm looking for is to be able to see them through 'TOP' like my 1st example above.
For a note one of my machines do that...
Finally I've found the answer.
In case anyone looking for the answer, suPHP or suEXEC is all that I need.
Quote:
suPHP is a tool for executing PHP scripts with the permissions of their owners. It consists of an Apache module (mod_suphp) and a setuid root binary (suphp) that is called by the Apache module to change the uid of the process executing the PHP interpreter.
Quote:
The suEXEC feature provides Apache users the ability to run CGI and SSI programs under user IDs different from the user ID of the calling web server. Normally, when a CGI or SSI program executes, it runs as the same user who is running the web server.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.