[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Setting Up Name Based Virtual Hosts in MAC Lion Server

Posted on 2011-09-14
4
Medium Priority
?
818 Views
Last Modified: 2012-05-12
I've been trying to set up Lion server to host multiple websites.

i've done a bunch of research and it seems to be a big problem and there seems to be many workarounds available, i've tried a few and have not been able to get any of them to work.

Does anybody know of a solid procedure to use?

Which configuration files would i need to modify? How would i modify them without breaking the rest of Apache?

Thanks for your help!
0
Comment
Question by:Cybervanes
  • 2
  • 2
4 Comments
 
LVL 81

Expert Comment

by:arnold
ID: 36540338

If you only have one, you would have to place it in the main configuration file
prior to the first virualhost entry where the default site is defined.
NameVirtualHost *

<virtualhost *>
#default site

</VirtualHost

<virtualhost *>
ServerName www.somesite.com

</virtualhost>

etc.
http://soft.zoneo.net/Linux/remove_empty_lines.php

http://soderlind.no/archives/2011/08/26/running-wordpress-locally-on-mac-os-x-lion/ has a link to a guide which might be more useful to you.

useful command apachectl configtest can be used to detect whether the changes you made are incorrect i.e. will cause an error and might prevent apache from starting.
0
 
LVL 2

Author Comment

by:Cybervanes
ID: 36540380
so if i wanted to take it a step further and and add multiple sites with specific paths i would use:

<VirtualHost *:80>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

after the first default site?

and thats all?

the main configuration file you are talking about is /etc/apache2/sites/0000_any_80_.conf or where would it be located?

thanks!
0
 
LVL 81

Accepted Solution

by:
arnold earned 1000 total points
ID: 36540665
Yes, but make sure you have the namevirtualhost * above the first site.

The links I posted provide a guide and examples.

You could add it in /etc/apache2/httpd.conf directly.
the example deals with setting up a mechanism that enables you to alter the configuration without elevating your rights which I would suggest you not follow.

It all depends on you, you could if not included at the bottom of httpd.conf
include conf.d/*.conf

What this provides is the ability for you to create domain.conf domain2.conf domain3.conf within /etc/apache2/conf.d that will minimize the entries/scope of data in /etc/apache2/httpd.conf while providing you with simpler management.

you might use the example they had with /etc/apache2/other instead of /etc/apache2/conf.d.

Note: you still need to include the NameVirtualHost * directive in httpd.conf above the default site's virtual host entry.

The conf files using * will relay to name based hosting,
Make sure to always backup the current copy prior to making any changes just in case.  Look into subversion which is a way to manage configuration files while subversion will maintain versions of the file just in case a change made leads to trouble.

0
 
LVL 2

Author Closing Comment

by:Cybervanes
ID: 36551258
ended up switching the ip address selection to the ip address of the server and that seems to have fixed it... doesn't make sense but it's working!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This is a tech scam I recently helped my parents through.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question