Virtual host “Forbidden You don't have permission to access / on this server” on debian

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>

        ServerAdmin [email protected]
        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
</Directory>

  </VirtualHost>

so I ran a2ensite test

and added

127.0.0.1 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


Solution 1:

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