0

I want to have multiple domains on my apache2.2 local server on Linux. I have edited the httpd.conf and inserted these codes after going through various posts on the internet.

NameVirtualHost *:80
<VirtualHost *:80>
   ServerName localhost
   DocumentRoot /home/jharvard/vhosts/localhost
</VirtualHost>

<VirtualHost *:80>
   ServerName ratnesh
   DocumentRoot /home/jharvard/vhosts/ratnesh
</VirtualHost>

the html folder is inside the 'localhost' and 'ratnesh' folders for each case. Then I edited the /etc/hosts files as follows:

127.0.0.1 localhost localhost.localdomain
127.0.0.1 ratnesh ratnesh.localdomain
127.0.0.1 appliance appliance.localdomain

Then I restarted the apache service. But of no help. When i try to visit localhost I am getting 403 FORBIDDEN error. And for visiting the ratnesh domain, it directs me to the google search. Furthermore, when i am removing the edited code (written above) from the 'httpd.conf' the localhost works fine but ratnesh doesn't. Stuck on this problem for a week and am really frustrated now.

Hope you'll help. Thanks.

Regards,

Ratnesh

  • your vhost directive is missing the block to allow the request... – Pascal Schmiel Jun 20 '13 at 16:01
  • Dependig on your distro you should also check for SELinux context (on RHEL/Centos) and folders owner and permissions. – Giorgio Previtera Jun 20 '13 at 16:24
  • folder owners and permissions are set accordingly. for the test purpose i have set all the permissions to world readable and executable. Now i added the block as per the answer below by Rakesh. Now getting Internal Server error. – Ratnesh Ray Jun 20 '13 at 16:48

1 Answers1

1

think the server wide directives deny access to all directories so you need to specifies these directories to give them access , note ive added your html directory to DocumentRoot.

 <VirtualHost *:80>
   ServerName localhost
   DocumentRoot /home/jharvard/vhosts/localhost/html

    <Directory "/home/jharvard/vhosts/localhost/html">
        Options Indexes FollowSymLinks
        AllowOverride None

        # Controls who can get stuff from this server.
        Require all granted

    </Directory>

    <IfModule dir_module>
        DirectoryIndex  index.php index.html index.htm
    </IfModule>

 </VirtualHost>
Rakesh
  • 11
  • 2
  • After making the changes when I tried to reach **localhost** I get the following error. "Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request." – Ratnesh Ray Jun 20 '13 at 16:45
  • Then enable an error log and see what's going on :) – Halfgaar Jun 20 '13 at 16:56
  • The content of error log is: **[Thu Jun 20 13:00:36 2013] [crit] [client 127.0.0.1] configuration error: couldn't perform authentication. AuthType not set!: /** Don't know how to authenticate.. :( – Ratnesh Ray Jun 20 '13 at 17:02
  • One more thing want to add, I have un-done all the editing in httpd.conf. removed all VirtualHost, NameVirtualHost. Only 'localhost' worked fine. Furthermore, I have removed all entries from **/etc/hosts/** still **localhost** is working fine.. Unable to understand How the browser is resolving 'localhost' to 127.0.0.1 – Ratnesh Ray Jun 20 '13 at 18:49