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

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