-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>
5
  • This will almost certainly be SELinux httpd_enable_homedirs
    – user9517
    Feb 11, 2014 at 11:33
  • @Iain I see that page, my permission for public_html is (drwxr-xr-x 751), why i cant change it using chmod 755 public_html as root access?
    – Hamidreza
    Feb 11, 2014 at 11:50
  • 1
    the perms you show above are 755 so you won't see them changing ...
    – user9517
    Feb 11, 2014 at 12:03
  • 1
    I think you should stop what you're doing and go read some documentation on Unix permissions and how they interact with the filesystem and processes.
    – user9517
    Feb 11, 2014 at 12:16
  • @Iain Just i confused for the error, i understand permission reading was my mistake.
    – Hamidreza
    Feb 11, 2014 at 12:21

1 Answer 1

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>

9
  • I change selinux to disable by setenforce 0 and changing /etc/sysconfig/selinux to disable. but error happen again.
    – Hamidreza
    Feb 11, 2014 at 11:36
  • getenforce = disabled.
    – Hamidreza
    Feb 11, 2014 at 11:37
  • before adding VirtualHost, http://server-ip worked fine. but after it both of them given forbidden error.
    – Hamidreza
    Feb 11, 2014 at 11:38
  • And nothing useful in the apache error log?
    – HBruijn
    Feb 11, 2014 at 11:38
  • 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, 2014 at 12:22

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