Virtual host will NOT work in MAMP but works on localhost:8888 - apache

Created a new Laravel project in htdocs in MAMP. Followed all the steps, added virtual hosts, changed conf file, etc/hosts, restarted mamp and my pc several times but I just can't get my virtual host to run.
however, when I am in the MAMP Dashboard I can navigate to my website -> website -> public and the default Laravel boilerplate page appears.
Has anyone had this issues with MAMP before? I gave up with XAMPP and Valet so it's my last chance here..
Specs
High Sierra 10.13.5 on 2015 MBP,
Composer version 1.6.5,
php 7.2.7
httpd.conf
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
httpd-vhosts
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Applications/MAMP/htdocs/website/public"
ServerName website.dev
</VirtualHost>
etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
#255.255.255.255 broadcasthost
#::1 localhost
127.0.0.1 website.dev

website.dev is technically a public url, so the browser is looking for it on the internet I guess. I was trapped once in this dreadful situation. changing the name to something like website.local should solve your issue. It did for me.

Related

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?

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.

Forwarding from subdomain to port not working

the problem:
I am running a Windows Vserver and on this server I'm running a standalone Grails app on port 8081, which means that when I open
localhost:8081 (local) or domain:8081
in the browser, I see the interface of the Grails app.
What I am looking for is a way to type
subdomain.domain
that forwards me to
domain:port
I have read that this can be done using a virtual host on Apache. I used the XAMPP Apache because I'm running XAMPP MySQL anyway.
I added this line to the WIndows host file:
127.0.0.1 subdomain.domain
and this part to apache/conf/extra/httpd-vhosts.conf:
<VirtualHost *:80>
ServerName http://localhost
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>
<VirtualHost *:80>
ServerName http://subdomain.localhost
Redirect / http://localhost:8081
</VirtualHost>
What I expected:
when I open domain I see the xampp admin interface
when I open subdomain.domain I see the Grails app (as domain:port)
What happens:
no matter wheather I open domain oder subdomain.domain I'm always forwarded to domain:port
What am I doing wrong?
Regards
H
Solution (no idea where the technical difference is):
<VirtualHost Server-IP:80>
ServerName http://domain
DocumentRoot "C:/xampp/htdocs"
</VirtualHost>
<VirtualHost Server-IP:80>
ServerName http://subdomain.domain
Redirect / http://domain:port
</VirtualHost>
I even didn't have to make any entries in the Windows host file. NameVirtualHost wasn't necessary either.

Virtual host on Apache 2 isn't working as excpected

I'm trying to set a development server on my OSX 10.8.2. The deployed site name is mattat.org.il so I'd like to set it to mattat.dev.
These are the steps I followed:
Uncommented the include for virtual hosts, in httpd.conf:
Include /private/etc/apache2/extra/httpd-vhosts.conf
added a virtual host to httpd-hosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/matanya/Sites/matat"
ServerName mattat.dev
</VirtualHost>`
Added the server name to etc/hosts:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost.
fe80::1%lo0 localhost
127.0.0.1 mattat.dev
Restarted Apache.
Now, when i go to localhost it takes me to the directory I've set for the virtual host, instead of taking me the the root directory (i.e Sites).
When I go to mattat.dev it is unidentified as a valid url, and simply interpreted as a Google search.
What am I missing?
.dev is not a valid TLD, your browser is not treating it as a URL. http://mattat.dev should work.
For not recognising localhost, check that you have a default directory in your httpd.conf for Apache to fall back on if it cannot find a virtual host, or alternatively add a second Virtual host for localhost.
<Directory "/Users/matanya/Sites/">
Options Indexes
Order allow,deny
Allow from all
</Directory>

Having challenges creating virtual servers on apache server for win7 (resolving hostname)

I have an apache server installed on my portable windows 7 machine using xampp as an interface. I've been working with a few people on an irc channel but must soon go to bed and replies are getting slower.
I have the following code added to my httpd.conf file:
#virtual servers
#Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost.MEALS
DocumentRoot C:\xampp\htdocs\MEALS
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.HA
DocumentRoot C:\xampp\htdocs\Hackers
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.WIK
DocumentRoot C:\xampp\htdocs\WhoIKnow
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.TUS
DocumentRoot C:\xampp\htdocs\Unity
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName localhost.PHP
DocumentRoot C:\xampp\htdocs\phpMyAdmin
DirectoryIndex index.php
</VirtualHost>
And I have the following configuration:
Setting environment for using XAMPP for Windows.
John#ASSIMILATER C:\xampp
# httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 localhost (C:/xampp/apache/conf/extra/httpd-ssl.conf:80)
*:80 is a NameVirtualHost
default server localhost.MEALS (C:/xampp/apache/to which there was conf/httpd.conf:512)
port 80 namevhost localhost.MEALS (C:/xampp/apache/conf/httpd.conf:512)
port 80 namevhost localhost.HA (C:/xampp/apache/conf/httpd.conf:516)
port 80 namevhost localhost.WIK (C:/xampp/apache/conf/httpd.conf:520)
port 80 namevhost localhost.TUS (C:/xampp/apache/conf/httpd.conf:524)
port 80 namevhost localhost.PHP (C:/xampp/apache/conf/httpd.conf:528)
Syntax OK
John#ASSIMILATER C:\xampp
#
However when I try to access localhost.PHP in my web browser it tells me the server is not found. I was instructed that I need to resolve the host names on my machine. I was directed to a few irc channels (dns and windows) to which there was no reply. I searched google and ran across this site: http://technet.microsoft.com/en-us/library/bb727005.aspx#EEAA. I'm not quite sure what I'm reading and as near as I can tell it doesn't quite give me a clear instruction on where to resolve the host name or a file to edit.
Also currently the default server is the top virtual server in the code. I would like to call localhost and show a simple html page I created which is in "htdocs/index.html" which will navigate to the other servers (links pointing to "localhost.PHP" etc). is there a way to have the default server remain "localhost" which points to "htdocs/index.html" while maintaining the other virtual servers, or will I have to create another virtual server and make that the default?
Any and all help appreciated.
edit: I had someone help me find the HOSTS file on my machine but am unable to edit it. I turned off all antivirus features, turned off spybot (UAC was always off and I always run with administrator privileges) specifically right clicked on np++ editpadlite and windows notepad and was only able to edit in notepad, but was required to save the file with a different name.
You have to explicitly run Notepad as an administrator (regardless of UAC settings) and when you go to save, make sure you select 'all files' rather than the default *.txt.
I found the same thing when I tried to edit the hosts file on W7, but it seems that just being an administrator on the machine isn't quite the same as explicitly running the program as an administrator.