Solved

Setting Up Name Based Virtual Hosts in MAC Lion Server

Posted on 2011-09-14
4
809 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 76

Expert Comment

by:arnold
Comment Utility

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
Comment Utility
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 76

Accepted Solution

by:
arnold earned 500 total points
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Information security is a multi-billion dollar industry. Just as lucrative is the black market industry which trades stolen identities, credit card numbers and software exploits all over the world. Nothing is hack-proof. The best one can do is make …
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now