Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Before I created a virtual host I could see "http://localhost", but when I created a virtual host I could not see "http://localhost" and my virtual host "http://test"

Here is my virtualhost config file:

<VirtualHost test:80>

        ServerName  test
        ServerAlias test

  DocumentRoot "/home/javad/Public/test/public"     
<Directory  "/home/javad/Public/test/public/" >
 Options Indexes FollowSymLinks
 MultiViews ExecCGI     
 DirectoryIndex index.php   
 AllowOverride all 
 Order    allow,deny 
 allow from all


so I ran a2ensite test

and added test to /etc/hosts file and restart apapche2 fine

But after that I cannot access to http://test or even http://localhost i get

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

When I delete my virtual host setting I can access http://localhost

share|improve this question

Once you activate virtualhost you need to reconfigure localhost as virtualhost. You can simply copy-paste httpd.conf parameters.

share|improve this answer

probably no index file in the directory and directory listing is disabled? - cann you access files directly?

otherwise check read permissions for the webserver user.

it looks weird to me to have a directory statment inside virtualhost container, its usually not the case altough if you can start your webserver it seems to work.

you need to have a namevirtualhost directive in place in order for your config to work correctly.

<VirtualHost test:80> ... try using *:80 or ip:80 instead. the resolution may cause problems here and make the virtualhost ineffective.

share|improve this answer
i have index file ,and why i could access to localhost when delete setting of test irtual host – ulduz114 Apr 16 '11 at 14:00
Without the vhost entry you can get to your server because you're accessing it via the default non-vhost setup. Joe is probably right about the permissions issue, can you confirm that you checked that? – muffinista Apr 16 '11 at 14:14
i ran "chmod -R 755 test" command to /home/javad/Public/test/public folder and /etc/www floders but still can not access to test or localhost – ulduz114 Apr 16 '11 at 14:37
its not possible to reliably determine the problem here. please your configuration files (server config including all vhosts and other user specific files if any). please paste them to some external service to keep it tidy. also supply the output or your access and error logfile(s). – The Shurrican Apr 17 '11 at 22:42

This is too long for a comment, so it's an answer I'll revise. Run this script and provide us with the output:

#!/bin/bash -x -e

cd /
ls -lhd .
cd home
ls -lhd .
cd javad
ls -lhd .
cd Public
ls -lhd .
cd test
ls -lhd .
cd public
ls -lhd .
ls -lh
share|improve this answer

When you create a vhost, you have to specify a vhost for your server as well, localhost in this case. See the highlighted section titled "Main host goes away"

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.