Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-04-15 17:11:50

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

[wiki] MAMP with Virtual Hosts

Thought I would add this here because before the TxB went nipples up I was looking at the MAMP docs and they not only said nothing of using virtual hosts but the doc was also outdated with broken download links and dated graphics (though I fixed the download link). Hence, and should the wiki be reanimated successfully, this thread might shine light on enhancing that doc.

My problem, as some know, is I have a new Mac and need to get local sites up and running quickly, but so far it has not been very quick, and slowing by the hour.

I’ve successfully installed MAMP and can run any number of sites from the token htdocs folder in MAMP, but as I’ve alluded to here (or maybe somewhere above that post), there’s a problem with that; namely, root-relative links that are setup for banner and footer links (primary navigation, logo images, utility links, etc.) in a given site, and which are added via Txp forms, don’t work in the local setup but do in the live site (as they should), which probably has something to do with the location of the funky MAMP working directory (htdocs).

Thus the need for Virtual Directories to get the root-relative behavior working equally at both local and live…so that no hair-pulling is needed later when you find that links are broken when loading db dumps one way or the other.

All the help I’ve seen for VD’s so far seems to discuss the issue from a raw install of Apache, not with one included with MAMP, and thus not the same paths to the http-config folders being discussed (plus I don’t see any “hosts” file in my Mac, which is also often refereed to in other people’s mac versions), which might be one reason I can’t get VDs working with mamp.

Is anyone using MAMP with VD’s, and if so can you describe your exact setup, including all the relevant files and mods. Much obliged.

Last edited by Destry (2007-04-15 17:21:15)

Offline

#2 2007-04-15 17:35:15

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: [wiki] MAMP with Virtual Hosts

Here’s a thread at mamp forum that seems to address the exact situation, and answers my question about the mysterious etc/hosts file. No follow up to that thread about success or not though…

That “mukilla” fella seems like a familiar name…Matt, what’s the story?

Offline

#3 2007-04-15 18:27:42

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: [wiki] MAMP with Virtual Hosts

Just to provide a bit more coverage…

I’ve used NetManager to clone localhost and named it: dev.mysite.com

My MAMP httpd-config file has Virtual Directory set like this…

#
# Use name-based virtual hosting.
#

NameVirtualHost 127.0.0.1

#  Leave this one alone - it makes sure that localhost works.
<VirtualHost 127.0.0.1>
	DocumentRoot /Applications/MAMP/htdocs
	ServerName localhost	
</VirtualHost>

#  Add new hosts here for development

<VirtualHost 127.0.0.1>
	DocumentRoot /Users/me/Sites/folder1
	ServerName dev.mydomain.com
</VirtualHost>

The folder indicated above, “folder1”, is where the local Txp site is installed.

My Mac hosts file is this…

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost http://dev.mydomain.com
255.255.255.255	broadcasthost
::1             localhost 

However, when going to dev.mydomain.com I go directly to my live site, not the local one.

Offline

#4 2007-04-16 01:29:14

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [wiki] MAMP with Virtual Hosts

Destry wrote:

My Mac hosts file is this...
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost http://dev.mydomain.com
255.255.255.255	broadcasthost
::1             localhost 

Should be better like this:
(Also flush hosts file after)

127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

127.0.0.1 mydomain.dev
127.0.0.1 myotherdomain.dev

BTW.: You can do all this from the TXB Bundle for TextMate, that I wrote, using the helper commands that are included.
( Open hosts file and flush it after )

regards, marios

Last edited by marios (2007-04-16 01:31:36)


⌃ ⇧ < ⌃ ⇧ >

Offline

#5 2007-04-16 07:55:49

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: [wiki] MAMP with Virtual Hosts

Destry, I tend to use the <txp:site_url /> tag for all my root relative links and I use MAMP. Can you give me an example of what you’re talking about in case I’ve missed something?


Offline

#6 2007-04-16 12:24:53

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: [wiki] MAMP with Virtual Hosts

You can also write it like this: either way, it’s the same:

127.0.0.1 localhost mydomain.dev myotherdomain.dev
255.255.255.255 broadcasthost
::1 localhost

regards, marios


⌃ ⇧ < ⌃ ⇧ >

Offline

#7 2007-04-17 19:03:14

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: [wiki] MAMP with Virtual Hosts

Thanks marios, I’ll give it a whirl. What does flushing the host file mean and how do you do it ?

ma_smith: I’ve had my URLs set a certain way for so long I never really got around to thinking about it to much, but now that you point that tag out, that’s clearly the smart thing to do; should work the same between local or live, no matter what path, yeah? So something like this should work… href-”<txp:site_url />/about” ?

By the way, I’m trying out SubEthaEdit as a text editor. I haven’t made up my mind yet but it’s pretty slick.

Last edited by Destry (2007-04-17 19:07:02)

Offline

#8 2007-04-17 19:38:21

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: [wiki] MAMP with Virtual Hosts

Destry,
Yep. you got it. Here’s a typical nav for me. This will work in either environment. Local or live. And apparently the db call is once for each page, so its very small.
Where the output looks like this:

  • Design
    • Web
    • Print
  • Notebook
  • For The Love
<ul id="nav_menu">
	<li id="nav_design"<txp:if_section name=",design">class="active"<txp:else /></txp:if_section>>
		<a href="<txp:site_url />">Design</a>
		<txp:if_section name=",design">
		<ul>
			<li <txp:if_category name="web-design">class="active"</txp:if_category> id="web"><a href="<txp:site_url />design/web-design">Web</a></li>
			<li <txp:if_category name="print-id">class="active"</txp:if_category> id="print"><a href="<txp:site_url />design/print-id">Print &amp; Id</a></li>
		</ul>
		</txp:if_section>
	</li>
	<li id="nav_notebook" <txp:if_section name="notebook">class="active"<txp:else /></txp:if_section>><a href="<txp:site_url />notebook">notebook</a></li>
	<li id="nav_forthelove" <txp:if_section name="for-the-love">class="active"<txp:else /></txp:if_section>><a href="<txp:site_url />for-the-love">for the love</a></li>
</ul>

Offline

#9 2007-04-17 20:02:59

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: [wiki] MAMP with Virtual Hosts

Boy, that’s tricky shaninigans you got there. :) Looks like your doing some second-level stuff, so the conditionals are probably useful there.

I just have single level, so I use body IDs to target my active states, which works pretty well for me…and is a little easier to read. Of course it only works because my Section/Page relationship is one-to-one (as opposed to many sections to one page).

So for example the About page gets <body id-“about”>

Then in the CSS

body#about ul#nav li.about a,
body#journal ul#nav li.journal a,
etc,
etc,
etc {text-decoration: underline;}

And then the txp form…

<ul id="nav">
<li class="about"><a href="<txp:/site_url />about" title="About this site">about</a></li>
<li class="journal"><a href="<txp:/site_url />journal" title="My articles">journal</a></li>
etc
etc
etc
</ul>

Fundamental stuff. (Note the included site_url tags.) :)

Last edited by Destry (2007-04-22 17:09:31)

Offline

#10 2007-04-17 20:14:27

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: [wiki] MAMP with Virtual Hosts

marios wrote:

( Open hosts file and flush it after )

Ah…I guess this is what you’re talking about.

Offline

#11 2007-04-22 09:04:40

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: [wiki] MAMP with Virtual Hosts

To put proper closure to this thread…

I could never get the living-e version of MAMP to work, whether out of the htdocs folder or virtual hosts. I checked paths, I checked them thrice, I flushed toilets…er…hosts files, but nada. So I uninstalled living-e MAMP and went with XAMPP’s MAMPP. Not only did I get it up and running the first time, but I have virtual hosts created exactly as I had them on the PC, so all my local sites are simply this in the browser address bar…

  • local.site1.tld
  • local.site2.tld
  • etc.

None of that localhost:8888/folder/site1 bull.

However, you won’t find instructions at XAMPP, their documentation sucks as ever, as does developer support in the forums (thankfully I didn’t have to rely on either) so I’ll write up a tute, one place or another.

Thanks to all who tried to help.

Offline

#12 2008-02-08 21:27:00

jaredigital
Member
From: Texas
Registered: 2004-10-26
Posts: 26
Website

Re: [wiki] MAMP with Virtual Hosts

Destry, as someone who is about to dip their toes into this whole local webserver business for the first time, a tutorial on how you got MAMPP to work would be awesome.

Offline

Board footer

Powered by FluxBB