Can't debug to fix virtual host issue on windows 10 - apache

I have problem when i try to setup virtual host on my windows 10 pc.
In my hosts file:
127.0.0.1 project.dev
In my httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#project.dev
DocumentRoot "path to project"
ServerName project.dev
ErrorLog "logs/project.dev-error.log"
CustomLog "logs/project.dev-error-access.log" common
<Directory path to project>
Require all granted
Allowoverride All
</Directory>
</VirtualHost>
httpd.exe run without error.
I try to run:
localhost
It works but when i try to run:
project.dev
in the browser, it does not work.
This site can’t be reached
project.dev refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
I have tried to solve this issue for hours but i can't.
Windows firewall logs, System logs, Applications logs, Apache logs don't show me any infos to help me.
Could anyone help me debug this issue?
Thanks!
------------UPDATE--------
Today, i updated php and apache to newer version
https://windows.php.net/downloads/releases/php-7.2.6-Win32-VC15-x64.zip
https://www.apachehaus.com/downloads/httpd-2.4.33-o110h-x64-vc14-r2.zip
and tried to run project.dev with simple vhost:
<VirtualHost *:80>
DocumentRoot "C:/Users/0x1111/workspace"
ServerName project.dev
#ServerName www.example.com:80
</VirtualHost>
Chrome shows https error:
Your connection is not private
Attackers might be trying to steal your information from project.dev (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_AUTHORITY_INVALID
Running localhost it works normal.
----UPDATE -----
when i use nslookup localhost:
Server: resolver1-fs.opendns.com
Address: 208.67.222.123
Non-authoritative answer:
Name: localhost
Addresses: ::1
127.0.0.1
But when i nslookup project.dev:
Server: resolver1-fs.opendns.com
Address: 208.67.222.123
*** resolver1-fs.opendns.com can't find project.dev: Non-existent domain

Related

Virtual hosts for MAMP 4.1.1 on MAC 10.12.6 not working

I know this has been asked hundreds of times and I made sure I read all of them, but still I cannot get this working. So as the title suggests, I cannot get a vhost running from MAMP/OSX. Here's a list of things I tried so far:
Created configuration in /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/abcd/public"
ServerName abcd.dev
ServerAlias www.abcd.dev
</VirtualHost>
Removed comment from the line
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
in the file /Applications/MAMP/conf/apache/httpd.conf
Finally this is how my /etc/hosts file looks
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 abcd.dev
Restarted MAMP and here are the test results:
http://localhost/ - Shows Index of and then /abcd
http://127.0.0.1/ - Shows Index of and then /abcd
abcd.dev - Unable to connect, Firefox was unable to connect to the server abcd.dev
Surprisingly
ping abcd.dev - Returns response 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.053 ms
ping 127.0.0.1 and ping localhost also returns same response.
I had docker running on my computer, I thought that was messing it up, so I stopped in completely, but the problem continues.
Any help is appreciated.
you have specified "www." prefix in your vhosts file, but tried to access is through abcd.dev (without the www.)
abcd.dev is now officially a public domain. So basically my browser is trying to locate the site "out there".
Instead let's use something like abcd.local or abcd.loc
Hope this helps someone stuck in .dev labyrinth.

Virtual Hosts Not Working under MAMP

I apologize for asking a question that's be asked before, but most of those questions have not been answered, and what few answers there are have not worked for me.
I am using Dreamweaver to build and manage my sites. Until now I have been successfully testing the sites on my remote host. But I want to add a database that I can test locally, so I am trying to use MAMP to create a virtual web server on my Mac (El Capitan, 10.11.5). Following standard instructions, after installing MAMP, I have edited the following files in my /private/etc folder as follows (showing only the changes):
etc/hosts
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
#127.0.0.1 fenixnest.pub.net
#127.0.0.1 fenixnest.dev.net
#127.0.0.1 fenixnest.tst.net
etc/apache2/httpd.conf
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
etc/apache2/httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/_FenixNest/"
ServerName fenixnest.pub.net
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/_FenixDev/"
ServerName fenixnest.dev.net
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/_FenixTest/"
ServerName fenixnest.tst.net
</VirtualHost>
Here are the results in my browsers (Safari and Chrome):
When I enter "localhost" I get the appropriate "It Works" page.
When I enter "localhost/fenixnest.dev.net", I get "The requested URL /fenixnest.dev.net was not found on this server." (The same for the "tst" and "pub" sites.)
When I enter "localhost/_FenixDev" (the name of the site root folder), I get "The requested URL /_FenixDev was not found on this server."
When I enter "fenixnest.dev.net", I get "This site can't be reached. fenixnest.tst.net’s server DNS address could not be found."
I have experimented with including "localhost/" as the prefix to the ServerName in both etc/hosts and etc/apache2/httpd-vhosts.conf. I have also tried commenting out the localhost block in etc/apache2/httpd-vhosts.conf (as suggested in one similar question). Nothing I have tried so far works.
I really would like to get a working virtual host on my Mac. Can anyone tell me what I'm doing wrong?

Virtual Host ERR_NAME_NOT_RESOLVED

I'm trying to set up a VirtualHost for laravel in apache on XAMPP.
I can access through Firefox, but if I type www.laravel.dev on Chrome I get this error "ERR_NAME_NOT_RESOLVED". Then, I tried to set it as "www.laravel.local" but it doesn't work either.
I followed this answer Google Chrome virtual hosts not working with ERR_NAME_NOT_RESOLVED error after update and when I flush it keeps on saying:
www.laravel.local IPV4 error: -105 (ERR_NAME_NOT_RESOLVED) 2015-06-23
16:53:09.090 [Expired]
This is my httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/laravel/public/"
ServerName laravel.local
ServerAlias www.laravel.local
</VirtualHost>
And the /etc/hosts
127.0.0.1 localhost
127.0.0.1 www.laravel.local
Thank you for your time.

Google Chrome virtual hosts not working with ERR_NAME_NOT_RESOLVED error after update

I started getting this error for all my local virtual hosts on apache in the morning when I updated my Chrome to the latest version on ubuntu.
While all of them work on other browsers chrome started misbehaving with ERR_NAME_NOT_RESOLVED error.
Screen shot for the error
Got it fixed like this:
Clear up the Chrome's DNS cache by typing this in the Chrome browser
chrome://net-internals/#dns
Screenshot -> Flushing Chrome DNS cache
You will see a button "Clear Host Cache". Press that DNS cache
will be flushed.
Keep this DNS window open. Now access the virtual host in the browser
for me it was http:/api.localhost. Once you do that you will see a
new entry in the DNS window. for me it was "localhost."
notice the period "." at the end of localhost that showed an error.
Last step is to simply add this entry as
127.0.0.1 localhost.
in the hosts file located at
for ubuntu : /etc/hosts
for windows : C:\Windows\System32\drivers\etc\hosts
Another solution could be to ditch the .localhost /.dev at the end of your local virtual host domain
This has to do with some new changes by google. ".dev" and ".local" comes under google's TLD (In the corner of the internet where people care about DNS, there is a bit of an uproar at Google's application for over a hundred new top-level domains, including .dev etc)
Use a domain name you own. Possibly using the full name like "localhost.dev.$yourdomain" could help here on the setup.
Here is how to fix xampp virtual hosts in chrome and firefox that are ending with .dev. who doesn't work anymore (in most versions of chrome, since .dev is real domain registered and reserved from google - [Dev domain ICANN]).
I had so much trouble, with getting virtual hosts working properly
on both firefox and chrome, but at the end i find out that the best solution
is to make two different hosts for each local domain. So i ended up with something like: Here is hosts file in (C:\Windows\System32\drivers\etc\hosts):
This is needed, becouse if you still want your localhost alive
127.0.0.1 localhost.
::1 localhost.
fe80::1%lo0 localhost.
This works fine in Firefox.
127.0.0.1 laravel.dev
::1 laravel.dev
fe80::1%lo0 laravel.dev
This works perfectly on Chrome.
127.0.0.1 laravel.localhost
::1 laravel.localhost
fe80::1%lo0 laravel.localhost
And here is my xampp httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "D:/xampp/htdocs/"
ServerName localhost
ServerAlias localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#laravel
DocumentRoot "D:/xampp/htdocs/laravel/public/"
ServerName laravel.dev
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#laravel
DocumentRoot "D:/xampp/htdocs/laravel/public/"
ServerName laravel.localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#testsite
DocumentRoot "D:/xampp/htdocs/testsite/"
ServerName testsite.dev
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#testsite
DocumentRoot "D:/xampp/htdocs/testsite/"
ServerName testsite.localhost
</VirtualHost>
I hope this helps for someone, because i lost a couple hours, finding out the best solution, and make the things work. :)
tags - virtual host doesn't work on chrome.
Another option is to replace in your file /etc/hosts any entry defined as your_domain.localhost with something like local.your_domain. But this would also require you to change the "ServerName" and "ServerAlias" value in your virtual hosts files.
For me is working this:
In hosts:
127.0.0.1 localhost.
::1 localhost.
fe80::1%lo0 localhost.
And In httpd.conf:
<VirtualHost localhost>
DocumentRoot "D:/Apache/htdocs/projects/some-project-root"
ServerName some-project.localhost
</VirtualHost>
Important is write to VirtualHost tag "localhost", "127.0.0.1" does not works in chrome.

Can't get wampserver 2.5 accessible from a remote machine

I desesperate to get wamp working!
I've installed wampserver 2.5 on my win7 64bits machine.
In the httdp.conf file, I just commented out the line regarding vhosts:
Include conf/extra/httpd-vhosts.conf
The httpd-vhosts.conf contains:
<VirtualHost *:80>
DocumentRoot "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev"
ServerName petsy.dev
ServerAlias www.petsy.dev
<Directory "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
<RequireAny>
Require local
Require ip 192.168.1
</RequireAny>
</Directory>
</VirtualHost>
(I also tried Require all granted)
I first installed wampserver 2.5 64 bits.
I was able, from my local machine to access http://petsy.dev
But when I tried to access to http://192.168.1.16/petsy.dev from an other machine of my LAN, I was always getting a 403 error (Forbidden):
[Thu Dec 04 14:43:08.519329 2014] [authz_core:error] [pid 11088:tid 776] [client 192.168.1.15:39975] AH01630: client denied by server configuration: C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev
[Thu Dec 04 14:43:08.635335 2014] [authz_core:error] [pid 11088:tid 776] [client 192.168.1.15:39975] AH01630: client denied by server configuration: C:/wamp/www/favicon.ico
I got access remotely to petsy.dev when I added in the remote PC hosts file the line:
192.168.1.16 petsy.dev
In that case, I was able, on my remote machine, to access to the server using 'http://petsy.dev'.
First I don't understand what does it change on the server side and secondly I cannot be satisfied by this solution as I cannot use it on a smartphone.
As I wasn't able to find an answer anywhere, I finally tried to install wampserver 2.5 32 bits!
Same problem! But with a different error:
I can ALWAYS access to my petsy.dev website locally but now, when I try to access it remotely, I get a 404 error (not Found) !!!
Here are the access logs of apache
From my local machine:
xxxx::7d1a:xxxx:9672:xxxx - - [05/Dec/2014:19:22:25 +0100] "GET / HTTP/1.1" 200 40438
From my remote machine:
192.168.1.15 - - [05/Dec/2014:19:22:30 +0100] "GET /petsy.dev/ HTTP/1.1" 404 295
httpd -T answers syntax OK
httpd -S says:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server localhost (C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf:23)
port 80 namevhost localhost (C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf:23)
alias localhost
port 80 namevhost petsy.dev (C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf:34)
alias www.petsy.dev
ServerRoot: "C:/wamp/bin/apache/apache2.4.9"
Main DocumentRoot: "C:/wamp/www/"
Main ErrorLog: "C:/wamp/logs/apache_error.log"
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex default: dir="C:/wamp/bin/apache/apache2.4.9/logs/" mechanism=default
Mutex authdigest-opaque: using_defaults
PidFile: "C:/wamp/bin/apache/apache2.4.9/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: APACHE24=Apache2.4
Please, please which stupid error did I make ????
You dont need the <RequireAny> so just try this
<VirtualHost *:80>
DocumentRoot "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev"
ServerName petsy.dev
ServerAlias www.petsy.dev
<Directory "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
Additional Info
I dont think you understand what is happening when you create Virtual Hosts.
Basically when Apache see's it has one or more Virtual Hosts configured, you are teling Apache that it is the server for more than one domain name. The important part in that sentence is more than one domain name.
This causes Apache to examine the domain name on each incoming connection. It will then match the domain name to one of its Virtual Hosts definitions and change the DocumentRoot and potentially other parameters to those set in that Virtual Host.
So the important thing is that you use a matching domain name in the browser of the other PC you are using to get to Apache with a domain name it knows about.
This would normally be done by a DNS Server on the real internet, but while you are inside your own local network i.e. safely behind your router you have to use another method. You could setup your own local DNS Server, but thats quite complicated.
So the simple solution is to use the HOSTS file on the other PC's in your network.
So on the other PC (not the PC running WAMPServer), edit the \windows\system32\drivers\etc\hosts file and add this
192.168.1.16 petsy.dev
Then either reboot or do this to reload the windows dnscache
Start a command windows using "Run as Administrator" and execute these 2 commands to reload the cache
net stop dnscache
net start dnscache
Now you can use the correct domain name from the browser on the non-wampserver pc like so
http://petsy.dev
And the browser will find that petsy.dev lives on ip address 192.168.1.16. When the connection is made with 192.168.1.16 it will be using the corretc domain name i.e. petsy.dev and apache will find the virtual host and set everything as per the VH config and server pages from the correct folder.
here is a great tutorial
Project Links do not work on Wamp Server
Answer #1 worked for me
I'm running windows 7 64 bit
I have wampserver2.5 (64 bit) installed on a hd assigned to letter A
All my dev sites are located on A:\websites
In A:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf I have this
<VirtualHost *:80>
DocumentRoot "A:/websites"
ServerName localhost
ServerAlias localhost
<Directory "A:/websites">
AllowOverride All
Require local
</Directory>
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "A:/websites/example.dev/www
ServerName example.dev
ServerAlias www.example.dev
<Directory "A:/websites/example.dev/www>
AllowOverride All
Require local
Require ip 192.168.10
</Directory>
</VirtualHost>
On the computer running wamp I adjusted the host file as follows
127.0.0.1 example.dev
::1 example.dev
On the local remote computer I've added an entry to the host file as
192.168.10.100 example.dev (this is the ip address of the computer running wamp)
next step is to clear your dns cache
open a terminal on the windows box that's not the web server
type "net stop dnscache"
type "net start dnscache"
Open a browser and point it to example.dev and it works
hope this helps