Textpattern tips, tutorials and code snippets

Setup your Mac localhost for local development

While thinking last week about updating the look and feel of this site, I started wondering how I was going to do this considering I had to change some of the markup, not just styling. In the past I have used MAMP which is mostly enough except that cookies don’t get set (I believe MAMP Pro makes this possible) but recently I tried a couple of other apps – SequelPro and VirtualHostX.

Note: I am no expert in this field so please read up fully before attempting any changes, and always backup first!

Get started

First, download and install MAMP, SequelPro and VirtualHostX.

Setting up your localhost

Apple Macs ship with pretty much everything you need for local development before pushing to a live server, but it does not include MySQL which you need for Textpattern development. MAMP is really nice to use because it includes MySQL, phpMyAdmin, Apache, PHP5 etc. If your needs are simple MAMP is all you need. However, if you want to develop using your own txptips.com domain URL and some other goodies, read on.

Install VirtualHostX and MAMP

The great thing about these apps is that they work together with MAMP to create a perfect localhost development environment. I started with this great article on setting up a killer localhost environment. The article is easy to follow so I won’t repeat it here, but these are the steps to follow:

  1. Download and launch MAMP
  2. Change default ports MAMP uses
  3. Download and launch VirtualHostX
  4. Backup settings (using VHX’s startup guide)
  5. Add the virtual hosts we want to use
  6. Restart Apache

Install SequelPro

Now we can download and install SequelPro. Its a lovely app which can be used for SSH connections. When you open the app you see a connection screen.

sequel pro
SequelPro connection screen

For connecting to your Mac, we need a Socket connection. By default, the username and password are root. When you create a database via this connection, a new database will be stored in your MAMP /db/mysql/ folder. You can edit or delete any database that you already have in that folder.

Working with VirtualHostX

With VirtualHostX you can use any URL you want, which in my case was perfect for TXP Tips. Although in this case I did not use txptips.com I could if I wanted. I had some issues with MAMP at this point, the solution apparently is to turn off web sharing.

virtual host x
VirtualHostX hosts screen

Working with Textpattern locally

Now for the fun part – working with a TXP install locally! Here is how I did it:

  1. Export the TXP Tips database from phpMyAdmin, then import into SequelPro as txptips_txp (replace with your preferred db name)
  2. Export the TXP Tips Textpattern install, then import into the /yourusername/Sites/txptips.site folder (replace with the name you set in VirtualHostX)
  3. Change config.php settings. You may also need to change TXP’s file and tmp directory paths

And that’s pretty much it. Visit http://txptips.site/ and http://txptips.site/textpattern in your browser and work away.

Useful links:

4 Comments Comment feed

  • bici
  • 29 November 2009

Hi – Nice article. But i am confused. My version of MAMP and Mac OS X come with MySQL as far as i know. I developed a local TxP site a few months ago. Since then i have upgraded to MAMP Pro and it seems to allow everything: multiple virtual hosts, mysql, myphp admin etc.

(PS I think it would useful to have a date stamp on your posts)

Cheers

Hi Walter – yes, as I say in the article, MAMP includes MySQL but Apple does not ship MySQL so you need either only MAMP/MAMP Pro or the three apps I talk about here.

I have not used MAMP Pro so I make no assumptions/claims, but I think you are right in that it allows for total local development.

The method I outline is free and allows for developing using any web url you want, that alone makes it worthwhile IMO.

Date stamp for the articles – that’s on the top right.

  • bici
  • 30 November 2009

ok. now i get it. I didn’t read it carefully enough. the first time!

( i see the date stamp ,,,waaaaayyy offf to the right ;-) )

Thanks.
cheers

Sure! The meta data has always been on the top right, I did not move it in the recent re-design.

Add a comment

Use Textile help to style your comments