Solved

Setting Up Name Based Virtual Hosts in MAC Lion Server

Posted on 2011-09-14
4
814 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 78

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 78

Accepted Solution

by:
arnold earned 500 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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In this article we have discussed about the OS X EI Capitan and how to fix Wi-Fi issue in OS X El Capitan. We have explained how to delete system level preferences and create a new Wi-Fi location to resolve Wi-Fi issue.
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 …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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