-1

In Directadmin (I used it before) when we create a reseller, a new user with a home directory was created and user could add domains in a home directory like /home/user/domains/example.com/public_html

How i can add /home/user/public_html as virtual host to apache web server? I want to config apache like direct admin to use home directory.

Im new on Centos 6.5 and i'm trying to config a web server. My OS is clear (no any configs, just DNS) and SElinux is disabled in /etc/sysconfig/selinux. I have one ip for my VPS.

Now my config for httpd is below.

<VirtualHost domain-1.com:80>
    DocumentRoot /home/user/domains/domain-1.com/public_html
    ServerName domain-1.com
</VirtualHost>

When i add this config, i get forbbiden error in http://domain-1.com and http://server-ip

UPDATE I added the following code to apache conf.d but the error is alive.

<IfModule mod_userdir.c>
    UserDir enabled user
    UserDir public_html
</IfModule>
<Directory /home/*/public_html>
        Options Indexes Includes FollowSymLinks
        Require all granted
        AllowOverride All
        Allow from all
        Order deny,allow
</Directory>
Hamidreza
  • 163
  • 1
  • 2
  • 9

1 Answers1

1

Depends a bit on the error message in your log files, a missing IndexDocument i.e. no index.html in the documentroot could be one obvious cause for that error.

The other common cause would be because you have SELinux enabled. Check that with getenforce.

And of course file system privileges on the path to the documentroot i.e. on /home/user and /home/user/domains/<etc>

HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • I change selinux to disable by `setenforce 0` and changing /etc/sysconfig/selinux to disable. but error happen again. – Hamidreza Feb 11 '14 at 11:36
  • getenforce = disabled. – Hamidreza Feb 11 '14 at 11:37
  • before adding VirtualHost, `http://server-ip` worked fine. but after it both of them given forbidden error. – Hamidreza Feb 11 '14 at 11:38
  • And nothing useful in the apache error log? – HBruijn Feb 11 '14 at 11:38
  • just this error: `(13)Permission denied: access to / denied` – Hamidreza Feb 11 '14 at 11:41
  • That is the error code for a file system permissions problem (One can check with `perror 13`). Quite useful. Check if the apache user can access the DocumentRoot with `ls -ld /home/user /home/user/domains/ /home/user/domains/domain-1.com /home/user/domains/domain-1.com/index*` – HBruijn Feb 11 '14 at 11:48
  • I tyred to login as apache user with `su apache` but it is not possible, how i can do this? – Hamidreza Feb 11 '14 at 12:01
  • 1
    The apache user typically has no valid shell, which is why you can't use `su apache`, what you can do is (as root) `sudo -u apache ls -ld /home/user /home/user/domains/` etc. But just checking owners groups and permissions of the directories and files doesn't have to be done as apache, root or even user would work just as well. – HBruijn Feb 11 '14 at 12:22
  • There is a problem with `/home/user/domains` permission. I change it by `chmod 777 /home/user/domains` to solved the problem. Thanks ;) – Hamidreza Feb 11 '14 at 12:31