I am an Apache/linux newbie. (Trying to learn this technology...)

I setup a Mandrake 10.1 server, and am trying to setup virtual hosting.

I created a user and a www folder. Set the www folder permission to 777.
I created a virtual server as follows:

<VirtualHost *>
DocumentRoot "/home/domain/www"
ServerName *.domain.com
<Directory "/home/domain/www">
allow from all
Options +Indexes
DirectoryIndex index.html index.htm default.htm
</Directory>
</VirtualHost>

I added the DirctoryIndex line, but get the same error with or without that line.

If I try to browse any file including the root site, I get the following error message:

Forbidden
You don't have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I'm assuming that this is a permission based issue, however I have 777 permissions set, so it should work. Any help would be appreciated!

Thanks!

Dani AI

Generated

Good instincts from and . A 403 from a vhost under /home almost always comes down to one of two things: Apache cannot traverse one of the parent directories, or the vhost you think is serving the request is not the one actually answering.

Start with the filesystem. The execute bit must be set on every parent dir, not just the DocumentRoot. Safer than 777 is:

  • chmod 711 /home /home/domain
  • chmod -R 755 /home/domain/www
    Also make sure ownership lets the webserver read the files. For example, if your content user is myuser and the webserver group is apache (or www-data on Debian/Ubuntu), use: chown -R myuser:apache /home/domain/www. World-writable 777 on a webroot is a security risk and can trip other protections.

Next, fix the vhost and access rules. ServerName does not take wildcards; use ServerAlias for that. For modern Apache 2.4, you also need an explicit allow. A minimal, safer example:

<VirtualHost *:80>
  ServerName domain.com
  ServerAlias www.domain.com *.domain.com
  DocumentRoot /home/domain/www
  <Directory /home/domain/www>
    Options -Indexes +FollowSymLinks
    Require all granted
  </Directory>
</VirtualHost>

Quick diagnostics that save time:

  • apachectl -S shows which vhost is matched by the Host header.
  • apachectl -t validates the config.
  • tail -f /var/log/httpd/error_log (or /var/log/apache2/error.log) shows the exact reason for the 403.
  • If you are using symlinks, enable FollowSymLinks as hinted.
  • On SELinux systems, label content and enable homedir reads if needed: restorecon -R /home/domain/www and setsebool -P httpd_enable_homedirs 1.

Finally, if you customized ErrorDocument 403, ensure that file itself is readable to avoid a 403-on-403 loop.

Recommended Answers

All 6 Replies

check your permissions... is /home/domain/www readable by apache? Also, is the server & virtHost name really wild-carded? This may be a problem... I usually specify (e.g. for domains I use locally <VitualHost 127.0.0.1:80> (also match <NameVitualHost 127.0.0.1:80> ) ...blah blah.. ServerName mydom.dom

Also, if you're using symbolic links, you my need that option used here

The previous post was pretty much head on, one thing that I noticed is that if the /home directory does not have the +x flag to everyone, then it may not be able to go into your directory, may want to do chmod +x /home

Good Answer to his question, I was going to say as well if you are creating a Web server to host people on or even your own stuff.

Please make sure you have Firewall, IPTables, and GRSecurity.

I am hoping you understand what I mean.

Thankx,
Michael :cheesy:

change the file permission of index.html to 644
chmod 644 home/domain/www/index.html

Thanks for the information, it was useful.

if you copy and paste in the /opt/lampp/htdocs it will cause this problem,, better create yourself new index.html file from leafpad and copy paste the materials ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.