1

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 javad@fish.com
        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

Caleb
  • 11,813
  • 4
  • 36
  • 49
ulduz114
  • 111
  • 1
  • 2

4 Answers4

1

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

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
KevOu
  • 11
  • 2
0

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.

The Shurrican
  • 2,240
  • 7
  • 39
  • 60
  • i have index file ,and why i could access to http://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 http://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
0

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
Jeff Ferland
  • 20,547
  • 2
  • 62
  • 85
0

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"

KM.
  • 1,786
  • 2
  • 18
  • 31