ad_728x90

參觀我的【 伊生活小舖】

2013年10月17日 星期四

How to create multiple local websites on a Mac Mini with Lion Server


Lion Server comes with a basic web service with a default site. So you get that up and running, and you’re all wanting to use your Lion Server as a testing environment for several local sites, not just a single site (i.e with virtual hosts) . It was a bit of a pain for me to get that set up. Googling around to figure out how to do it resulted in me finding bunches of people complaining about how Snow Leopard was better for such things. I eventually figured it out, though, and pieced the instructions together here:

1.) Move your directory (or create a new directory) in:
[Hard Drive]/Library/Server/Web/Data/Sites/
2.) Add the site to the Server application under Services -> Web. For settings I used:
Domain Name: myurl.local
IP Address: Any
Port: 80
SSL: none (I’m sure you can stick this in later)
Store Site Files In: Find your directory from #1
I just left everything else as default.
3.) In a terminal, edit /etc/apache2/httpd.conf
sudo vi /etc/apache2/httpd.conf will open the file in Vi with write access
Edit this file and add this: NameVirtualHost *:80
4.) Navigate to: /etc/apache2/sites/ (cd /etc/apache2/sites/)
Look for a file ending in [newurl].local.conf
Edit this file and add this: NameVirtualHost *:80
5.) Edit the /etc/hosts file and add this to the list of hosts:
127.0.0.1 myurl.local
6.) Restart the web service using these commands:
sudo serveradmin stop web
sudo serveradmin start web
7.) Open a browser and navigate to newsite.local, and (in theory at least) the site should load!
YMMV on these instructions – I started in at the point where the default local site was already set up and working, so I’d make sure that’s all good before jumping in. Also, I’m still not completely sure if #4 negates the need for doing #3. So, feel free to try this while skipping #3, in case I totally stuck in a redundant step.

COMMENTS HAVE BEEN DISABLED FOR THIS POST [文章的評論已被禁用]

Ratings and Recommendations by outbrain