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!
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:
- Download and launch MAMP
- Change default ports MAMP uses
- Download and launch VirtualHostX
- Backup settings (using VHX’s startup guide)
- Add the virtual hosts we want to use
- Restart Apache
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.
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.
Working with Textpattern locally
Now for the fun part – working with a TXP install locally! Here is how I did it:
- Export the TXP Tips database from phpMyAdmin, then import into SequelPro as
txptips_txp(replace with your preferred db name)
- Export the TXP Tips Textpattern install, then import into the
/yourusername/Sites/txptips.sitefolder (replace with the name you set in VirtualHostX)
config.phpsettings. You may also need to change TXP’s file and tmp directory paths
And that’s pretty much it. Visit
http://txptips.site/textpattern in your browser and work away.