Virtual host installation not working

1

I am trying to instal my existing local server with xampp. I setup apache to point to mywebsite.dev document root to /code/www/public. I get an error saying The webpage is not accessible. This website has the same address as an external website.

Instructions i m following:

Create a folder on your computer for the files 
Edit your host file to add the site name 
Edit httpd-vhosts to add the VirtualHost 
Restart Apache using the XAMPP Control Panel 


127.0.0.1  //Mywebsite.dev

<VirtualHost *:80>
    DocumentRoot C:\Mywebsite\trunk\www\public
    ServerName //Mywebsite.dev    
    <Directory C:\Mywebsite\trunk\www\public>
        Order allow,deny
        Allow from all
    </Directory>   
</VirtualHost>

NewPassionnate

Posted 2016-12-07T21:38:34.250

Reputation: 13

Do not use .dev as a TLD locally you will run in all sort of problems. It is a valid generic TLD, owned by Google. You should not invent names locally and hope they will work and not create collisions. Instead create a domain name and then just name your resources locally like something.dev.example.com or something.internal.example.com or something.private.example.com, etc. About .DEV: https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/

– Patrick Mevzek – 2018-09-05T15:02:45.950

Answers

1

I get an error saying The webpage is not accessible.

There are several mistakes in your configuration.

Your host file:

127.0.0.1  //Mywebsite.dev
  • Remove the // from the entry in the hosts file.

Corrected hosts file:

127.0.0.1  Mywebsite.dev

Your httpd-vhosts.conf file:

<VirtualHost *:80>
    DocumentRoot C:\Mywebsite\trunk\www\public
    ServerName //Mywebsite.dev    
    <Directory C:\Mywebsite\trunk\www\public>
        Order allow,deny
        Allow from all
    </Directory>   
</VirtualHost>
  • Remove the // from the ServerName

  • Replace \ with /

  • Quote the DocumentRoot and Directory

Corrected httpd-vhosts.conf file:

<VirtualHost *:80>
    DocumentRoot "C:/Mywebsite/trunk/www/public"
    ServerName Mywebsite.dev    
    <Directory "C:/Mywebsite/trunk/www/public">
        Order allow,deny
        Allow from all
    </Directory>   
</VirtualHost>

DavidPostill

Posted 2016-12-07T21:38:34.250

Reputation: 118 938

it is saying forbidden access – NewPassionnate – 2016-12-08T02:34:00.470

@NewPassionnate That's a different problem. Please post a new question. – DavidPostill – 2016-12-08T10:21:59.113

0

To solve the problem forbidenn access I changed in my httpd-conf:

<Directory>
    AllowOverride none
    Require all denied
</Directory>

by :

 <Directory>
   Options Indexes FollowSymLinks Includes ExecCGI
   AllowOverride none
   Require all granted
</Directory>

NewPassionnate

Posted 2016-12-07T21:38:34.250

Reputation: 13