Friday, April 24, 2015

Trying Craft Client or Pro on Mac OS X Before Buying

Craft allows you to try Craft Client and Craft Pro before buying them, by running your site from the host name craft.dev or a subdomain such as site1.craft.dev (link). However, it's not immediately obvious what "running your site from craft.dev" means.

This post explains how to run your site from craft.dev on Mac OS X using MAMP and Sequel Pro.

1 — Install Craft on MAMP

  • The first step is to install Craft Personal. These instructions explain how to do that on Mac OS X using MAMP and Sequel Pro.

2 — Create a directory for the craft.dev site

  • Go to /Applications/MAMP/htdocs
  • Create a new folder trybeforebuy/public/ (or whatever you want to call it)  
  • Copy contents of the htdocs folder there, including the hidden .htaccess file
  • Edit $craftpath in index.php to be '../../../craft'

3 — Setup craft.dev as an Apache virtual host 

  • Follow these video instructions 
  • Use 'craft.dev' (no quotes) as the ServerName
  • Use "/Applications/MAMP/htdocs/trybeforebuy/public/" (with quotes) as the DocumentRoot and Directory 

4 — Change the Web port to 80 from 8888

  • Open MAMP
  • Switch to the Ports tab
  • Click on the “Set the Web & MySQL ports to 80 & 3306” button

5 — Access the new Dashboard 

  • Go to http://craft.dev/admin/login 

6 — Upgrade your Craft installation

  • Click on the "Show me" link in the "Upgrade Craft to take your site to the next level" box at the bottom of your Dashboard
  • Click on the "Test" link by Craft Client or Client Pro, whichever you want to explore
That's it!

This post describes how to switch between the different versions--Craft Personal, Craft Client, and Craft Pro--if you want to do that.

Saturday, April 4, 2015

Installing Craft CMS on Mac OS X Using MAMP & Sequel Pro

I just wanted to set up Craft CMS on my Macbook to experiment with. It took me forever. This explains what worked (and what was missing from other sets of instructions).

Craft's install documentation assumes but doesn't explain several prerequisites (like setting up my MySQL) and The Absolute Beginners Guide to Setting Up Craft on Mac (sounded perfect) was directionally helpful but had some errors and, at the end of the day, simply didn't work for me. For the longest time, I could not get Craft to connect to MySQL, even though it was installed correctly and running.

These are the perquisite steps, assuming you aren't already running Apache and MySQL:
  • Step P1: Download and install MAMP -- This sets up a Macintosh, Apache, MySQL, and PHP solution stack and gives you a simple management interface to start and stop the servers.
  • Step P2: Download and install Sequel Pro -- This gives you a simple tool to manage your MySQL databases.
  • Step P3: Open MAMP (not MAMP Pro), and click "Start Servers" -- This starts the Apache Web server and the MySQL database engine.
  • Step P4: In MAMP, click "Open WebStart page," if MAMP didn't already open one in your browser automatically.
  • Step P5: Open Sequel Pro, and use the parameters on MAMP's WebStart page to create a connection -- I could not create a Standard connection using '127.0.0.1'. I had to create a Socket connection, using 'localhost'. This is the scenario that the Craft installation instructions don't anticipate.
  • Step P6: Click the control in the upper lefthand of Sequel Pro, and choose "Add Database ..." to create a database, e.g.. 'crafted'. Choose UTF-8 for “Database Encoding."
These steps track those in Craft's installation instructions but with some additional explanation. Read them together:
  • Step C1: Upload the files -- You're uploading the files, because you're pushing them to your Apache Web server on your Macbook.
    • Download Craft -- It will end up in your Downloads folder. There are two folders craft/ and public/ in the downloaded 'Craft-2' folder.
    • Copy the craft/ folder to /Applications/MAMP, i.e., above the webfoot (htdocs/). 
    • Copy the files htaccess, index.php, and robots.txt from public/ to the htdocs/ folder.
    • Rename htaccess to .htaccess -- Open Terminal and run the following commands:
      • "cd /Applications/MAMP/htdocs" -- go to where htaccess lives 
      • "defaults write com.apple.finder AppleShowAllFiles -bool true" -- show hidden files
      • [Relaunch the Finder] -- hold down control-Alt while you click on Finder in the dock and then choose Relaunch
      • "mv htaccess .htaccess" -- rename htaccess
      • "defaults write com.apple.finder AppleShowAllFiles -bool false" -- hide hidden files
      • [Relaunch the Finder again]
  • Step C2: Set the permissions
    • Open Terminal and run the following commands:
      • "cd /Applications/MAMP/craft" -- go to the craft/ directory
      • "chmod -R 744 app"
      • "chmod -R 744 config"
      • "chmod -R 744 storage"
  • Step C3: Create your database 
    • Nothing to do here -- You already did this in Step P6 above.
  • Step C4: Tell Craft how to connect to your database
    • Copy the default settings in "craft/app/etc/config/defaults/db.php" into "craft/config/db.php"
    • Update the parameters
    • Set 'unixSocket' to the Socket value on your MAMP WebStart page (e.g., "/Applications/MAMP/tmp/mysql/mysql.sock"). 
  • Step C5: Run the installer! 
    • The URL is "localhost:8888/admin"
    • Follow the installation screens
I'm guessing that if you are setting up Craft in a production environment on a production Mac you might want to do somethings a little different, but this will get you a sandbox to play in. Enjoy!