开发者

How do I determine the user Apache is run as?

How to check what is Apache user?

I need to give read write permission to it, for some directories in my web root and outside of 开发者_如何学Pythonthee web root directory, how can i do that?

Since I dont have proper idea of what Apache user is, I cannot answer my next question.


ps aux | egrep '(apache|httpd)' typically will show what apache is running as.

Usually you do not need to change the default user, "nobody" or "apache"


At the very least you need to specify the OS you are using. Look in your httpd.conf for the "User" directive. It will tell you what user apache will run as.


The apache2 user can be found out as follows. Go to /etc/apache2/apache2.conf and look for User

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

To find out the value for APACHE_RUN_USER and APACHE_RUN_GROUP, check in /etc/apache2/envvars

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data


You may try to use the following command to check it:

ps axo user,group,comm | egrep '(apache|httpd)'

Or further more (to extract exact username) via:

ps axo user,group,comm | egrep '(apache|httpd)' | grep -v ^root | uniq | cut -d\  -f 1
ps axo user,group,comm | egrep '(apache|httpd)' | grep -v ^root | tail -1 | awk '{print $1}'

For Apache group, use the following command:

ps axo user,group,comm | egrep '(apache|httpd)' | grep -v ^root | uniq | cut -d\  -f 2


Answer 1: what is an Apache user and where it is defined

In my default http.conf file located under /etc/apache2/httpd.conf (this file location varies by OS ) om my MAC, apache user is _www ( default user name as it comes with apache download )

since I see this in my httpd.conf

User _www

Answer 2: how do I give this user the read write permission to a folder "foo"

check who owns foo, by doing ls -l
# Use chown command to make _www ( apache user ) own "foo" folder
chown _www foo
# user chmod +666 to make this "foo" folder read write accessible
chmod 666 foo

good two min read on permissions http://www.macinstruct.com/node/415


Apache user is typically the user that the apache httpd server uses when running. It uses this "apache" user to avoid having to use a "human" user, and to avoid having to run as root.

Advantages of installing an "apache" user include not having to run as root, so during the handling of http requests, there is less risk in damaging and losing the entire operating system.

The only real disadvantage of having an "apache" user is that you need to make web presented content accessible to the "apache" user. That typically involves a combination of the unix commands chown, chmod, and sometimes various selinux commands.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜