VirtualHosts loading blank pages in Mavericks - apache

I'm having issues loading VirtualHosts I've setup on my iMac, all that they appear to be returning are blank pages. I've tried multiple browsers, flushed my DNS cache, cleared browser cache etc but nothing appears to be fixing this.
Here is what my /etc/apache2/httpd-vhosts/conf file looks like:
NameVirtualHost *:80
<Directory "/Users/chris/Sites/test/">
Allow From All
AllowOverride All
</Directory>
<VirtualHost *:80>
ServerName "test.dev"
ServerAlias "test.dev.*.*.*.*.xip.io"
DocumentRoot "/Users/chris/Sites/test"
</VirtualHost>
Here is what my /etc/hosts file looks like:
##
# 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
fe80::1%lo0 localhost
# VHX START
127.0.0.1 test.dev
fe80::1%lo0 test.dev
# VHX STOP
In my /private/etc/apache2/httpd.conf file I've made sure to uncomment the following line:
Include /private/etc/apache2/extra/httpd-vhosts.conf
I'm using VirtualHostX to manage all of this but I've even resorted to deleting everything in these files and starting again following guides online – that didn't work either.
I've tried to tail the apache access log and whenever I try to access http://test.dev nothing shows up in that file or the apache error log – it's as though my machine has absolutely no idea that URL exists even though I believe everything is setup correctly.
Any ideas on how I can fix this?
Thanks,
Chris

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.

Xampp vhost cannot load the virtualhost without port number

I am not sure if this is a repost but I couldn't find a solution.
I have an application setup in my local environment which the name I added in my hosts file (C:\Windows\System32\drivers\etc) as follows,
127.0.0.1 skeletonpage.lk
Also I added a record in httpd-vhosts.conf as below.
<VirtualHost *>
DocumentRoot "C:/xampp/htdocs/skeleton/public"
ServerName skeletonpage.lk
<Directory "C:/xampp/htdocs/skeleton/public">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I run the application on browser I can only load the homepage with the port number tagged with the site name. Ex: http://skeletonpage.lk:83/
I have both XAMPP and WAMP in my machine and my site runs in XAMPP for which the port 83 is given, If I remove :83 it loads the homepage of wamp server which has port 80.
I tried removing and modifying above code snippet but still cant get rid of port 83. I know this is something simple, but would be glad if someone can help.
I modified as <VirtualHost *:83> also <VirtualHost 127.0.0.1:83> and restarted XAMPP also modified NameVirtualHost *:83 but no use.

Apache 2.2 Virtual Host not working

I'm trying to set up a virtual host for a local site - something I've done literally hundreds of times - but something's going wrong this time.
My files are in C:\wwwroot\TEMPLATESITE
I have the following in my hosts file (last in a list of similar hostnames that all work)
127.0.0.1 templatesite.localhost.com
I have the following VirtualHost set up in my httpd-vhosts.conf (again, alongside a handful of other, identically set up, working sites)
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.
DocumentRoot c:\wwwroot\TEMPLATESITE
ServerName templatesite.localhost.com
ErrorLog logs/templatesite.-error_log
CustomLog logs/templatesite.-access_log common
</VirtualHost>
(I've tried both with and without a trailing slash on the DocumentRoot)
Yet, no matter what I try, no matter how many times I restart Apache, or my machine, when I type in templatesite.localhost.com I end up at the root of c:\wwwroot which is my localhost root.
I'm guessing the problem is in my hosts file since the logs don't have any attempts to even access TEMPLATESITE so it seems like the hosts file is failing back to the generic localhost.
In that light, here's my entire hosts file:
127.0.0.1 lmm.localhost.com
127.0.0.1 lmm2.localhost.com
127.0.0.1 prairie.localhost.com
127.0.0.1 pinegrove.localhost.com
127.0.0.1 cas-pc.localhost.com
127.0.0.1 lksu.localhost.com
127.0.0.1 localhost
127.0.0.1 templatesite.localhost.com
Thoughts?

Enabling virtual hosts in Apache makes every host forbidden (403)

I am on Windows 8 and just now installed Wamp 2.5 (Apache 2.4.9) at C:/wamp to test my code locally. I have my source code repository at D:/workpace/project1 which I manage using GIT (GIT is one of the reasons I don't want to disturb its location).
After Installing Wamp, I just went on to enable virtual hosts by uncommenting the following line in httpd.conf.
#Include conf/extra/httpd-vhosts.conf
Then I headed to conf/extra/httpd-vhosts.conf created its backup and created the virtual host.
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "D:/workspace/project1/"
ServerName project1
ServerAlias p1
ErrorLog "logs/project1(local)-error.log"
CustomLog "logs/project1(local)-access.log" common
<Directory "D:/workspace/project1/">
Require all granted
</Directory>
</VirtualHost>
Also edited the hosts file and added the necessary lines.
127.0.0.1 project1
127.0.0.1 p1
The problem is that I get 403 Forbidden error not just when I access project1/ and p1/, but also when I access localhost/.
When I disable httpd-vhosts.conf in httpd.conf by commenting out,
Include conf/extra/httpd-vhosts.conf
I am able to access localhost/ but as expected, project1/ and p1/ too resolve to localhost/.
Surprisingly, when I re-enable httpd-vhosts.conf in httpd.conf and restore the backup of original(unchanged) httpd-vhosts.conf, I still get 403 (Forbidden) even on localhost/. But again when I disable httpd-vhosts.conf, localhost/ comes to normal.
It is furthermore surprising to note that If I change DocumentRoot to a dummy folder within c:/wamp/www, the story is the same. So this is not just happening when DocumentRoot is outside c:/wamp/www.
I feel that I have something extra to enable because there is no chance I have messed up anything as this is a fresh installation and I have made no changes except the ones above.
What may be the reason Apache is not getting along with virtual hosts?
There are a few things that you have not taken into account.
When you create Virtual Hosts Apache ignores the host defined in httpd.conf so you also need to create a Virtual Host for localhost. This explains why you cannot get to localhost when you have activated Virtual Hosts.
Apache is IPV4 and IPV6 aware, so when you create your domain names in the HOSTS file you need to do so for both the IPV4 and IPV6 stacks. So you would need to have a HOSTS file like this :-
#IPV4 Stack
127.0.0.1 localhost
127.0.0.1 project1
#IPV6 Stack
::1 localhost
::1 project1
The browser makes some arbitrary decision on whether to use the IPV4 stack or the IPV6 stack. Wish I understood why and for what reason it makes this decision better, but basically when you enter a domainname, the browser, or the networking stack, picks IPv4 or IPv6 for your first contact to a domain and then sticks to that decision, but it could use either.
Here is a post that should help you create Virtual Hosts

XAMPP apache server not using the ports I desire, not certain why

So, I've been setting up this HTTP server for a school project that has to be able to maintain multiple domains through virtual hosts. Using XAMPP I have my server set up, I thought I'd done it properly but perhaps not.
I had heaps of issues with not being able to listen to a port, to solve this I used (in httpd.conf under apache/conf/)
Listen 0.0.0.0:8080
ServerName localhost:8080
If I used 80/81/8080/321/any combination that did not have the prefix 0.0.0.0 it told me the port could not be listened or whatever (sorry, a little rusty with my syntax).
I set up my first virtual host up like so (under apache/conf/extra/httpd-vhosts.conf):
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "H:/xampp2/xampp/htdocs"
ServerName localhost:8080
<Directory "H:/xampp2/xampp/htdocs">
Option Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I thought this seemed all good and well and I don't believe I've modified anything else. To me, I would expect that this means my Apache server would use port 8080 for the server? However, when I start Apache in XAMPP it states quite clearly
Apache started [Port 80]
Why would this be port 80?
In conjunction, localhost:8080 doesn't navigate me to the documents, but localhost:80 or localhost do. I presume that this just means it's still on port 80. I've tried resetting my computer and XAMPP.
If you need any more information, please let me know. I tried following guides such as this one: http://ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/
Cheers.
Oh, I also edited my Windows HOSTS file; it looks like so:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 localhost:8080
Edit: New error... Now getting this when I init, doesn't seem to be affecting it though:
ERROR: Status Check Failure [3]
This program must be run from your XAMPP root directory.
It is being run from teh root directory as far as I can tell.
Ok Im not advanced in this area either. However after much playing around with XAMPP and following a few different guides I got mine working.
The Host under drivers seems abit weird. I declared mine as:
127.0.0.1:8080 test.localhost.com
127.0.0.1:8080 test2.localhost.com
Back up you Xampp, then extract a clean install to C: - Just because that Status check failure sounds like bad news.
!Remember to run setup_xampp.bat from the xampp directory and install the apache service!
Then under you httpd.conf add:
ServerRoot C:\xampp\apache
Listen 7070
Listen 8080
Listen 9090
Apache might not like that at first but meh.
The ServerRoot may already be declared above the Listen spot so just double check.
After that head to C:\xampp\apache\conf\extra.
Edit the httpd-vhosts.conf.
Under the section Name-based virtual hosting add:
NameVirtualHost *:7070
NameVirtualHost *:8080
NameVirtualHost *:9090
There will be a couple of examples of virtual hosts below that. Add:
<VirtualHost *:7070>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR1"
ServerName test.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR1">
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:9090>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR2"
ServerName test2.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR2">
Allow from all
</Directory>
</VirtualHost>
Not the double slash in the Directory tag. Now ensure there is an index.html under each of those directories. Restart the apache (Stop, start).
I cant navigate to the test.localhost.com URLs, probably due to the fact they are terribly wrong in the HOSTs config. Though I can connect to 127.0.0.1:7070, 127.0.0.1:9090 and access the webpages from there.
Also 127.0.0.1:8080 connects me to the xampp welcome panel that localhost used to connect you too.
Hope this helps and good luck!
I'm pretty sure that saying 'listening on port 80' is hard-coded into XAMPP, regardless of the port you use. Thus, your code should work fine.
In my .conf file, it just says "listen 80" instead of Listen 0.0.0.0:8080
Cheers.