LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache running as me (https://www.linuxquestions.org/questions/linux-server-73/apache-running-as-me-4175678128/)

JamesMore 07-04-2020 09:02 AM

Apache running as me
 
I have setup server with Apache (Centos 8) but it looks like I have Apache running under my user account.

Is that bad ? my account has access to sudo, Should I create another user and have it running as that user?

If so how do I do that, thanks for your help

pan64 07-04-2020 09:22 AM

yes, it is not the suggested configuration. I think you can specify the user in httpd.conf. Usually a user is created for this: www-data

michaelk 07-04-2020 11:38 AM

How did you set up Apache? Did you install it from the repositories?

By default CentOS configures apache to run as user apache.

ps aux | egrep '(apache|httpd)'

JamesMore 07-05-2020 10:02 AM

Thank you both for the reply here is the output of PS, As you cans see it is showing root on one process and my username near the bottom of the list

Code:

[JamesMore@myServername ~]$ ps aux | egrep '(apache|httpd)'
apache      787  0.0  3.4 282304 28784 ?        S    Jul01  0:04 php-fpm: pool www
apache      788  0.0  3.3 282020 28240 ?        S    Jul01  0:02 php-fpm: pool www
apache      789  0.0  3.3 282032 28476 ?        S    Jul01  0:02 php-fpm: pool www
apache      790  0.0  3.3 282032 28212 ?        S    Jul01  0:02 php-fpm: pool www
apache      791  0.0  3.3 282020 28224 ?        S    Jul01  0:02 php-fpm: pool www
apache      5262  0.0  3.3 282020 28368 ?        S    Jul02  0:02 php-fpm: pool www
apache      5372  0.0  3.3 282172 28288 ?        S    Jul02  0:02 php-fpm: pool www
root      10120  0.0  1.6 280592 14000 ?        Ss  Jul03  0:15 /usr/sbin/httpd -DFOREGROUND
apache    14663  0.0  1.0 293668  9128 ?        S    03:37  0:00 /usr/sbin/httpd -DFOREGROUND
apache    14664  0.0  1.7 1482232 15000 ?      Sl  03:37  0:10 /usr/sbin/httpd -DFOREGROUND
apache    14665  0.0  1.7 1351096 14980 ?      Sl  03:37  0:09 /usr/sbin/httpd -DFOREGROUND
apache    14666  0.0  1.9 1351096 16628 ?      Sl  03:37  0:09 /usr/sbin/httpd -DFOREGROUND
apache    15327  0.0  1.7 1351096 14788 ?      Sl  13:11  0:01 /usr/sbin/httpd -DFOREGROUND
JamesMore    15475  0.0  0.1  12108  1064 pts/1    R+  14:57  0:00 grep -E --color=auto (apache|httpd)


JamesMore 07-05-2020 10:27 AM

Sorry tweaked the PS output to not show my user name (This might have made me think my user was running apache)

Does this look ok from my limited knowledge apache is stated as root and then the child processes are ran as the user apache

Code:

[JamesMore@myServername httpd]$ ps aux | egrep --color '([a|A]pache|[h|H]ttpd)'
apache      787  0.0  3.4 282304 28784 ?        S    Jul01  0:04 php-fpm: pool www
apache      788  0.0  3.3 282020 28240 ?        S    Jul01  0:02 php-fpm: pool www
apache      789  0.0  3.3 282032 28476 ?        S    Jul01  0:02 php-fpm: pool www
apache      790  0.0  3.3 282032 28212 ?        S    Jul01  0:02 php-fpm: pool www
apache      791  0.0  3.3 282020 28224 ?        S    Jul01  0:02 php-fpm: pool www
apache      5262  0.0  3.3 282020 28368 ?        S    Jul02  0:02 php-fpm: pool www
apache      5372  0.0  3.3 282172 28288 ?        S    Jul02  0:02 php-fpm: pool www
root      10120  0.0  1.6 280592 14000 ?        Ss  Jul03  0:15 /usr/sbin/httpd -DFOREGROUND
apache    14663  0.0  1.0 293668  9128 ?        S    03:37  0:00 /usr/sbin/httpd -DFOREGROUND
apache    14664  0.0  1.7 1482232 15000 ?      Sl  03:37  0:10 /usr/sbin/httpd -DFOREGROUND
apache    14665  0.0  1.7 1351096 14980 ?      Sl  03:37  0:10 /usr/sbin/httpd -DFOREGROUND
apache    14666  0.0  1.9 1351096 16628 ?      Sl  03:37  0:10 /usr/sbin/httpd -DFOREGROUND
apache    15327  0.0  1.7 1351096 14788 ?      Sl  13:11  0:01 /usr/sbin/httpd -DFOREGROUND


scasey 07-05-2020 01:59 PM

The user running the web server (httpd) is apache.
The line with your username in #4 is the grep command...has nothing to do with httpd. It matches your grep....(doh)

Your conclusion in #5 is correct.

Please use code tags when posting output. See the link in my signature.

rnturn 07-12-2020 03:10 PM

Quote:

Originally Posted by JamesMore (Post 6141743)
Sorry tweaked the PS output to not show my user name (This might have made me think my user was running apache)

It had ya goin' there for a minute, didn't it. [heh]

I found it handy to search ps output using:
Code:

$ ps -ef | grep something | wogrep
where "wogrep" (WithOut GREP) is an alias:
Code:

$ alias wogrep='grep -v grep'    # Put it $HOME/aliases and source it in your profile
That way if you're counting (or whatever) processes your grep doesn't affect the result.

HTH...

shruggy 07-12-2020 03:50 PM

I usually just enclose the first character in square brackets similar to what the OP did in #5.
Code:

ps -ef | grep [s]omething
BTW, trying to run httpd on CentOS as any other user than apache would probably fail because of wrong SELinux context.

scasey 07-12-2020 08:50 PM

Quote:

Originally Posted by shruggy (Post 6144691)
I usually just enclose the first character in square brackets similar to what the OP did in #5.
Code:

ps -ef | grep [s]omething
BTW, trying to run httpd on CentOS as any other user than apache would probably fail because of wrong SELinux context.

On my server, the http user is nobody...but I’ve been moving this setup through upgrades since (I think) RH 3...around 1999.
Still, your point is valid...one shouldn’t mess with what the out-of-the-box installation wants to do.


All times are GMT -5. The time now is 01:30 AM.