Solved

Setting Up Name Based Virtual Hosts in MAC Lion Server

Posted on 2011-09-14
4
811 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 77

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 77

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Create a default user profile for Mac OS X 10.7/10.8 Create a user account on OS X that will be a template for every other user of that computer. I usually call it “profile” and make it an administrator account for the time being. 1. Install a…
A common question or need, when setting-up a new Mac for someone would be to make all of the applications, installed, available from the dock. Many people often do not realize an application is installed unless it is in the dock. Creating a custo…
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 …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

777 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