virtual host for xampp on Mac - apache

in my httpd-vhost.conf on macos 10.15.4,
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/theb/"
ServerName theb.localhost
ServerAlias www.theb.localhost
#DirectoryIndex index.html
<Directory "/Applications/XAMPP/xamppfiles/htdocs/theb">
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride none
</Directory>
ErrorLog "logs/theb.local-error_log"
</VirtualHost>
I have also included the virtual host in httpd.conf
Include etc/extra/httpd-vhosts.conf
Then in the host file, i have
127.0.0.1 localhost
127.0.0.1 www.theb.localhost
The issue im facing now with these configs is that whenever i browse the site in my browser,
http://www.theb.localhost, i will then be redirected to http://www.theb.localhost/dashboard ( which is the xampp default project folder). did i miss something out??

Restart Apache. Hopefully that will work.
If you have downloaded the VM version of Xampp (The one that gets mounted) then this wont work as it doesn't have access to your local files, get the non VM one here https://sourceforge.net/projects/xampp/files/XAMPP%20Mac%20OS%20X/7.4.6/xampp-osx-7.4.6-0-installer.dmg/download

Related

This site can’t be reached - XAMPP ignores custom domain vhosts

Environment
XAMPP 7.2.4 installed on Windows 10
Apache running on ports 80 and 443
Configuration
C:\Windows\System32\drivers\etc\hosts:
127.0.0.1 www.test.local test.local
C:\xampp\apache\conf\httpd.conf:
DocumentRoot "D:/htdocs"
<Directory "D:/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
C:\xampp\apache\conf\extra\httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot D:/htdocs
ServerName localhost
<Directory "D:/htdocs">
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot D:/htdocs
ServerName test.local
<Directory "D:/htdocs">
Allow from all
</Directory>
</VirtualHost>
The problem
When I start Apache and I access to localhost is all right. The problem comes when I try to reach test.local: the browser returns a This site can’t be reached message. It's like XAMPP ignores the custom domain vhosts defined into httpd-vhost.conf file. The same message is displayed with the server off.
This site can’t be reached
The webpage at http://test.local/ might be temporarily down or it may have moved permanently to a new web address.
ERR_ADDRESS_INVALID
A few days ago the setup was working and the only changes that I made was the new software installation. I mean, no changes in Apache config files.
If all your stack were working correctly before, don't be like me and don't forget to check if some browser extension is blocking your local traffic, like some extension related with an antivirus system.
In my case it was the Kaspersky Protection extension. When something goes wrong, it shows the following graphic.
C:\Windows\System32\drivers\etc
127.0.0.1 test.local
C:\xampp\apache\conf\extra\httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "C:/wamp64/www/test"
ServerName test.local
<Directory "C:/wamp64/www/hydroboost/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Have you updated your C:\Windows\System32\drivers\etc\hosts file with a mapping like this this?
add this line to the end of the hosts file
127.0.0.1 test.local
the localhost domain works without this mapping, because the OS already recognizes "localhost" as a built in alias for the loopback IP address
(this suggestion is assuming that you are running and testing on the same local machine)

OS X Apache2 vhosts hosts domain not working

Setting up my local dev environment due to an update in OS X pushing new Apache Files.
This setup works fine when going to localhost or http://127.0.0.1 but when I setup the hosts file like so
127.0.0.1 bears.dev www.bears.dev
bears.dev just comes up with "This site can't be reached" in chrome.
Below is my vhosts configuration setup. I'm stumped as to why this isn't work, i'm pretty sure it worked previously.
<VirtualHost *:80>
ServerName bears.dev
ServerAlias www.bears.dev
DocumentRoot "/Users/Bears/Dev"
ErrorLog "/private/var/log/apache2/bears.dev-error_log"
CustomLog "/private/var/log/apache2/bears.dev-error_log" common
ServerAdmin superbear9000#gmail.com
<Directory "/Users/Bears/Dev">
Options FollowSymLinks Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Thanks for the assistance!
In hosts file don't add two domains in line
right way is:
127.0.0.1 www.bears.dev
127.0.0.1 bears.dev

How can I get virtual host to work with XAMPP?

I just reinstalled XAMPP on my Win 7 machine yesterday. I am working on a Laravel project. I installed the current version of Laravel and then I went to set up the virtual host on the local machine. When I go to the url I set up (jrd_dnd_tools.localhost) I get a Bad Gateway message If I go to localhost I get the site the url is supposed to go to. I've set up virtual hosts before but no idea why this is happening. I'm sure I am missing something stupid but can't figure out what.
httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#jrd_dnd_tools.localhost
DocumentRoot "C:\Users\Joey\Web\jrd_dnd_tools/public"
ServerName jrd_dnd_tools.localhost
ServerAlias www.jrd_dnd_tools.localhost
ErrorLog "logs/jrd_dnd_tools.localhost.log"
CustomLog "logs/jrd_dnd_tools.localhost.log" common
<Directory "C:\Users\Joey\Web\jrd_dnd_tools/public">
AllowOverride All
Order Allow,Deny
Allow from all
## --New way of doing it
Require all granted
</Directory>
</VirtualHost>
.hosts
127.0.0.1 localhost
::1 localhost
::1 database.localhost
127.0.0.1 jrd_dnd_tools.localhost
What you have mistaken is *:80, for virtual hosts never use wildcards. Instead you can do jrd_dnd_tools.localhost. Here below is my virtual host setup, I did for demo.
And also notice directory separators I have in Document Root and directory.
Make these 2 changes and your virtual host will work like a charm.
<VirtualHost t.com:80>
ServerAdmin webmaster#t.com
DocumentRoot "C:/xampp/htdocs/t"
ServerName t.com
ServerAlias t.com
## ErrorLog "logs/jrd_dnd_tools.localhost.log"
##CustomLog "logs/jrd_dnd_tools.localhost.log" common
<Directory "C:/xampp/htdocs/t">
AllowOverride All
Order Allow,Deny
Allow from all
## --New way of doing it
Require all granted
</Directory>
</VirtualHost>

Problems in setting up VirtualHost using WAMP server

I want to host multiple websites on my computer. I'm using Windows with WAMP server. I already have domains and know how to map them to ip.
I have already edited httpd.conf file to allow virtual hosts.
My httpd-vhosts file looks like this,
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp64/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www/testcase"
ServerName test.mydomain.com
<Directory "C:/wamp64/www/testcase">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www/test2"
ServerName test2.mydomain.com
<Directory "C:/wamp64/www/test2">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
The problem is that both my domains open only the first site in this VirtualHost tag.
Example: In this case, both my domains will open the WAMP server configuration page. If I were to move the "testcase" tag above the other, both my domains will open the "testcase" page.
Update:
My subdomains show corresponding pages successfully when I open them on the server. But when I open subdomains on another machine, they open the first entry in the VH.
Update 2: Okay, so this is just out of my understanding now. I thought may be WAMP is not my cup of tea. So I installed XAMPP and made changes to the VH configuration and still ended up with same problem. So I then got rid of XAMPP too and installed WAMPDeveloper Pro. What could go wrong when the software sets up all the configuration files for you, right? But to my surprise, I still have the same problem. The websites work fine when I open them (using actual domain name) on the server itself, but when I open them on machine outside network the first VH entry open for all the domains I open.
Can anyone please help me with this?
Thanks!
Using both Apache2.2 and Apache2.4 syntax gets Apache a litle confused.
So as I assume you are running Apache 2.4 change the VH defs to this
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www/testcase"
ServerName test.mydomain.com
<Directory "C:/wamp64/www/testcase">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp64/www/test2"
ServerName test2.mydomain.com
<Directory "C:/wamp64/www/test2">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Why Apache opens the first site i.e. localhost in this case.
If Apache cannot make sense of a VH def, it ignores it and default to loading the first Virtual Host that was correctly defined in the httpd-vhosts.conf file.
Of course you will also need to amend your c:\windows\system32\driverrs\etc\hosts file to include these domain names
127.0.0.1 localhost
127.0.0.1 test.mydomain.com
127.0.0.1 test2.mydomain.com
::1 localhost
::1 test.mydomain.com
::1 test2.mydomain.com

Windows 7 - XAMPP: vhost keeps redirecting

My hosts file. (Win 7 ultimate)
127.0.0.1 localhost
127.0.0.1 efmm.local
My httpd-vhosts.conf (XAMPP 1.7.3)
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost efmm.local>
DocumentRoot "C:\xampp\htdocs\EFMM"
ServerName efmm.local
ErrorLog "logs/efmm.localhost-error.log"
CustomLog "logs/efmm.localhost-access.log" combined
<Directory "C:\xampp\htdocs\EFMM">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Problem
When I go to efmm.local , the browser redirects to localhost/EFMM.
I also tried <VirtualHost 127.0.0.1:80> instead of <VirtualHost efmm.local>, same result.
Here's how I do it on XP (don't expect it to make any difference in 7)
First, add the virtual host's domain to your HOST (as you did)
I don't put the virtual host webroot under the main htdocs directory. I create a specific webroot next to it, which gives me the following tree:
C:\XAMPP\htdocs
C:\XAMPP\htdocs-seconddomain
C:\XAMPP\htdocs-thirddomain
etc..
So in your case, I would create c:\XAMPP\htdocs-efmm alongside C:\XAMPP\htdocs
Then:
Edit XAMPP's httpd.conf, add and define any Apache options for the new document root, i.e.:
<Directory "C:/XAMPP/htdocs-efmm">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
[any extra apache module instructions you may require]
Order allow,deny
Allow from all
</Directory>
Edit XAMPP's httpd-vhosts.conf, adding the virtual host:
<VirtualHost *:80>
ServerName efmm.local
ServerAlias www.efmm.local
DocumentRoot "C:/XAMPP/htdocs-efmm"
ErrorLog "C:/XAMPP/htdocs-efmm/error.log"
DirectoryIndex index.php index.html index.htm
</VirtualHost>
Restart XAMPP. You may browse your new virtual host now.