How to add /home/user/public_html as virtual host in apache - centos
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>
Related videos on Youtube
Hamidreza
Updated on September 18, 2022Comments
-
Hamidreza over 1 year
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
andhttp://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>
-
user9517 about 10 yearsThis will almost certainly be SELinux httpd_enable_homedirs
-
Hamidreza about 10 years@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?
-
user9517 about 10 yearsthe perms you show above are 755 so you won't see them changing ...
-
user9517 about 10 yearsI 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.
-
-
Hamidreza about 10 yearsI change selinux to disable by
setenforce 0
and changing /etc/sysconfig/selinux to disable. but error happen again. -
Hamidreza about 10 yearsgetenforce = disabled.
-
Hamidreza about 10 yearsbefore adding VirtualHost,
http://server-ip
worked fine. but after it both of them given forbidden error. -
HBruijn about 10 yearsAnd nothing useful in the apache error log?
-
Hamidreza about 10 yearsjust this error:
(13)Permission denied: access to / denied
-
HBruijn about 10 yearsThat 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 withls -ld /home/user /home/user/domains/ /home/user/domains/domain-1.com /home/user/domains/domain-1.com/index*
-
Hamidreza about 10 yearsI tyred to login as apache user with
su apache
but it is not possible, how i can do this? -
HBruijn about 10 yearsThe 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. -
Hamidreza about 10 yearsThere is a problem with
/home/user/domains
permission. I change it bychmod 777 /home/user/domains
to solved the problem. Thanks ;)