Local virtual hosts pointing to the same directory
Asked Answered
W

2

7

I have been getting lost amidst forum posts on this issue.

1) I have MAMP (not Pro) Installed

2) My Apache port is set to 8888

3) My Document Root in preferences is set-up to /Users/usr/Sites

I want to set-up multiple local subdomains i.e.

private/etc/hosts

127.0.0.1    local1.sitename.com
127.0.0.1    local2.sitename.com
127.0.0.1    local3.sitename.com

No that is where the problem arises. In the httpd-vhosts.conf I tried to set up the following:

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "/Users/usr/Sites/Site1Name“
  ServerName local1.sitename.com
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "/Users/usr/Sites/Site2Name“
  ServerName local2.sitename.com
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "/Users/usr/Sites/Site3Name“
  ServerName local3.sitename.com
</VirtualHost>

etc.

For some reason all of these subdomains point to the same localhost:8888 document root directory. What am I doing wrong?

Thanks

Whiffet answered 4/2, 2014 at 16:30 Comment(6)
You have dublicate ServerName in the second virtual host.Horst
Sorry, I haven't. It's just a copy/paste typo. Has this got anything to do with the port 8888?Whiffet
Port is OK. Do you have some warnings in log? Try to ask this type of question at serverfault.comHorst
error log of apache, or see apachectl configtestHorst
This is all I get: Syntax OK. By the way I have changed port to 80. Will edit my question.Whiffet
I believe you need to change the vhost port from 80 to 8888. Not positive though.Selimah
W
1

I fixed this issue somehow by simply typing the directive for my virtual hosts as follows"

<VirtualHost *:80>
    DocumentRoot /Users/usr/Sites/Site2Name/
    ServerName local.Site2Name
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /Users/usr/Sites/Site3Name/
  ServerName local.Site3Name
</VirtualHost>

Don't ask me to explain why did this fix the problem though. If anyone knows the answer, let me know.

Whiffet answered 7/2, 2014 at 18:0 Comment(1)
I always get this problem with Apache. No feedback or way to debug it. I can see why nginx has taken overRuhl
B
0

Adding below code on apache\conf\extra\httpd-ssl.conf fixed the issue for me.

General setup for the virtual host

DocumentRoot "C:/xampp/htdocs/mysite.local"
ServerName mysite.local
ServerAdmin [email protected]
ErrorLog "C:/xampp/apache/logs/error.log"
TransferLog "C:/xampp/apache/logs/access.log"
Brought answered 9/4 at 2:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.