I removed user and group related to apache, (preinstalled with apache from RPM).

I'm in the process of installing Apache HTTPD from binary source "tar.gz"

  1. Download httpd-2.4.12.tar.gz
  2. Extrat tar zxvf /.../httpd-2.4.12.tar.gz -C /usr/local/
  3. Create link ln -s /usr/local/httpd-2.4.12 /usr/local/httpd
  4. Installed apr-1.5.2.tar.gz and apr-util-1.5.4.tar.gz (because is needed)

Later, later

#./configure --prefix=/usr/local/httpd --with-included-apr --with-included-apr-util
-with-pcre=/usr/local/pcre --with-z=/usr/local/zlib
# make
# make install

So far there were no problems...

Later after editing /usr/local/httpd/conf/httpd.conf and running the server /usr/local/httpd/bin/apachectl, it works perfectly...

Now, I want to create user and group for my Apache directory /usr/local/httpd

Question 1:

Do I need a system account, e.g., useradd -r -s /sbin/nologin apache?

I want to put my html files in: /usr/local/Html (for example), editing in httpd.conf file DocumentRoot and < Directory "usr/local/Html">

Question 2:

What user must be used, root or apache, for my dirs:?

chown -hvR apache: /usr/local/httpd
chown -hvR apache: /usr/local/Html

Question 3: What and how the permissions must be assigned to the owner with chmod?

chmod -R 750 /usr/local/Html


chmod -R 775 /usr/local/Html/

PS: I was reading (Not strictly following) http://www.linuxfromscratch.org/blfs/view/svn/server/apache.html

Thank you!

I have problems!

# useradd -g root -r -c "Apache User" -s /sbin/nologin apache
# chown -hvR apache:root /usr/local/httpd/

Using (there is no problem)

# /usr/local/httpd/bin/apachectl

but trying to use the recently created apache user, I have:

# /bin/su -p -s /bin/sh apache /usr/local/httpd/bin/apachectl start
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address
no listening sockets available, shutting down
AH00015: Unable to open logs

1 Answer 1

  1. Answer: Yes if you have deleted the user of apache that came up with rpm, you need to create on named as apache or www whatever, here -s /sbin/nologin apache indicate do not add the shell for apache user

    useradd -r -s /sbin/nologin apache

You can put your web files whatever you want /srv/www, /var/www/ or /usr/local/httpd anywhere, but it must be defined in httpd.conf file with DocumentRoot directiv and the web directory must have the appropriate ownership with the user apache and group of root aka

chown -R apache:root /srv/www

note: if you are running selinux in Centos and planning to put webfiles in /var/www the selinux context must be labelled well for that directories , which can be done using below command

semanage fcontext -a -t httpd_sys_content_t '/srv/www(/.*)?'
restorecon -Rv /srv/www

you can verify by running sesatus command whether your system has selinux enabled or not, running selinux is considered as good security practice

  1. Answer The user must be apache (your newly created user) with the group of root

  2. Answer The permission mode of 755 OR 750 are considered as idle for Linux web hosting

  • Hi thank you @user4820, 1) Using useradd the group is created implicitly, in this case the apache group. I don't know what is the reason to apache belong root group. 2) In my scheme: /usr/local/httpd needs execution permissions and /usr/local/Html needs read, writte and delete permissions.
    – QA_Col
    Commented Jul 8, 2015 at 16:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .