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

The 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

The 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:

comments powered by Disqus