Creating a CakePHP environment using MAMP and OS X

This will show you how to create a CakePHP environment in MAMP on OS X. Here list of softwares used and their version.

  • OS X Leopard or Snow Leopard
  • MAMP version 1.91 (using PHP5.2.x)
  • CakePHP 1.2.8

You shouldn’t have to use MAMP 1.9.1. I have it working on version 1.8.x. You will need to change Apache’s port from 8888 to 80. Make sure there aren’t any other web servers running on the same port. Leave MySQL running on port 8889. We will be creating a /Applications/MAMP/conf/apache/sites file that will store your virtual sites. It isn’t necessary but it’s easier to manage new sites on a separate file. You will need to edit the /Applications/MAMP/conf/apache/httpd.conf file by adding the following lines of code.

# virtual hosts file
Include /Applications/MAMP/conf/apache/sites

This will tell Apache to check the new sites file for additional configurations. So now, whenever you need to add or create a new site, you will edit the sites file and add the following code.

<VirtualHost *:80>
DocumentRoot /Users/username/Sites/projectname
ServerName projectname.local
</VirtualHost>

The value of DocumentRoot can be different. I just chose to put it in that folder. Now you will need to edit your /etc/hosts file by adding the following code.

127.0.0.1          projectname.local

Restart your MAMP server. Now unzip the CakePHP files into the projectname folder. You should now be able to view your new CakePHP site by directing your browser to http://projectname.local. This page will tell you that you need to change the default Security.Salt value. All you need to do is change at least one character and you will meet the requirement. You can also use Terminal to generate your own.

echo -n ‘foobar’ | openssl sha1

This will give you a 40 character string. You can use a mixture of upper and lower case on the letters. Copy and paste this value from Terminal to give a new Security.Salt value.

The next warning is your database. Rename the database file and edit it. Provide your database server information. Because MySQL in MAMP is using port 8889, you will have to edit the array and add the following.

‘port’ => ’8889′

There are notes in this file to help you further with additional array elements.

To use Terminal with the cake command, you will have to edit you ~/.bash_login file and create aliases. Here is the code to add to your .bash_login file.

# php
alias php5=”/Applications/MAMP/bin/php5.2/bin/php”

# cake for this project
alias cake=”php5 /Users/username/Sites/projectname/cake/console/cake.php”

To apply

. ~/.bash_login

You should be able to run

cake help

If you get a permission denied error, give it executable access with this.

chmod +x /Applications/MAMP/bin/php5.2/bin/php

That’s it. You can now start baking in a development environment. I know I have skipped a few steps but I’m assuming you know the basic commands and configurations. If not, please feel free to comment and ask questions. I’m still new with the MVC framework and CakePHP so go easy on questions regarding those. I am learning, slowly… haha!

Snow Leopard upgrade surprise

My work recently ordered our Snow Leopard DVD so we can upgrade our iMacs. I did my usual Time Machine backup and upgraded. I didn’t worry much about compatibility since my personal 13″ MBP has been running SL for a few months now and it had the same apps installed – no problems at all.

After I upgrade my work’s iMac, there were problems. I kept getting errors from my Symantec antivirus (I had to install it, work policy even though it isn’t necessary). I reinstalled it and it warned me to install Rosetta. I thought that would be the “aha” so I installed it. It looks like it fixed that problem, but now my Adobe CS3 apps crashes when I launch them. I Googled and it turns out there is an existing compatibility issue with CS3 and SL. It’s weird though since my MBP runs CS3 without a problem.

So now I got another external firewire hard drive. What I’m going to do is restore a backup that I made in Time Machine before upgrade onto an external hard drive. This way I can make sure that’s a clean copy before formatting and restoring it onto my iMac’s hard drive. This is why I love using Macs. When running into problems, I have several options to restore without losing data – as long as you back up data.

Once this is complete and I’m satisfied with the restored data, I will restore the backup onto the iMac. Then I’ll format the external drive and install a clean copy of SL and migrate my Leopard over to see if it’s SL or just my iMac configurations.

New Address Book sync options in 10.5.3

Apple recently released 10.5.3 update for Leopard. One of the updates I’m excited about is the ability to sync Address Book with Google and Yahoo!. If you want to set up a sync with Yahoo!, view this page http://help.yahoo.com/l/us/yahoo/addressbook/autosync/autosync-20.html. For Google, visit this page http://googlemac.blogspot.com/2008/05/mac-os-x-1053-sync-google-contacts.html. The only problem I found so far is with Google and contacts that have “Company” checked on your Address Book. These contacts seem to show up as blank in the contacts list (http://www.google.com/support/contactsync/#anchor_link_9). But if you click on it in Gmail, it will display the information.

Allowing network connections to MySQL in OS X Leopard Server

For the past couple of days I’ve been trying to set up one of our XServe running Leopard Server at work for web hosting. I was able to configure the Web, AFP, and SMB properly. The problem I was having was configuring MySQL. It was easy to enable but trying to connect to it from other computers in the same domain was the problem. There’s a checkbox with “Allow network connections” in the Server Admin section of MySQL. So I checked it, save, and restarted it. I still wasn’t able to connect. I checked for firewall settings. I pinged the host and got a response. I couldn’t figure out what was wrong. So I googled it.

The common answer I found was to edit the /etc/mysql/my.cnf file. Well it’s not there but I did find a /etc/my.cnf file. So I tried editing that file and restarting. It didn’t work.

Then I remembered that the php.ini file that Leopard Server is using isn’t in the default location /etc/php.ini, but it ran the /private/etc/php.ini. So I looked in there and found another my.cnf file. I edited the file by adding # in front of skip-networking entry. I restarted it and it finally worked.

So here’s what you need to do:

  • Go into Server Admin and check the Allow network connections and save
  • Comment out the skip-networking entry from /private/etc/my.cnf
  • Add the IP address of the computer you will be accessing MySQL remotely
  • Give it the privileges it needs
  • Restart MySQL

That should allow you to connect to MySQL running on Leopard Server remotely.

OS X Leopard: First thoughts and upgrade troubles

I just want to let you know the experience I had with upgrade to Leopard from Tiger. The upgrade went smooth on my PowerMac G5. It took about 48 minutes. All my apps seem to still be compatible.

Then I started to upgrade my MacBook Pro. Things looked normal. The trouble started after my laptop restarted once the upgrade process completed. It was stuck in the all too familiar blue screen of death (Apple version). I felt like I was back in Windows again. Apparently, it’s giving many people problems as well – http://discussions.apple.com/thread.jspa?threadID=1195031&tstart=0.

I left it on that screen over night and woke up this morning still in the same screen. There are 2 possible solutions that I’ve read so far in that long list of discussion.

Option 1: Archive and Install. This is the route I took and so far it seems to work. There are reported issues with Mail crashing when doing this method though. I don’t use Mail much so it is not a concern. This will require more hard drive space, I believe an extra 4GB is needed.

Option 2: Restart in Single User mode and enter some commands. I would’ve tried this by the time I read the post, I was already doing the Archive and Install. There is a chance that your administrator rights will be removed.

So far:

- Time Machine lives up to the hype. You are still able to use the selected external hard drive as a regular storage drive along with using it with Time Machine.
- Browsing other computers on the network have never been easier.
- Spotlight will be indexing your files after the install/upgrade. Depending on how much data you have, will determine how long it takes. On my G5 it took about 30. It will not prevent you from doing other things. It runs quietly in the background.
- Quick Look is great and fast. Viewing files from Windows displays the “blue screen of death” as the icon.

Hope this helps you guys. Even though I had problems upgrading my laptop, I still feel it’s worth the upgrade. Just make sure to back up.

And finally, I am glad I got to experience an Apple release event. There were about 200 people in line as they started to sell Leopard. It’s interesting that even though there are not many Apple users as Windows users; whenever Apple has something new to offer, majority of its users respond.

UPDATE: My MBP was affected by the admin bug. I was worried for a moment and I didn’t feel like doing a clean install tonight. Here’s what I did:

  1. Shutdown
  2. Turn on the computer and hold down Apple + S to get in to single user mode
  3. Type: /sbin/mount -uw /
  4. Type: passwd
  5. Enter your new password for root
  6. Confirm it by retyping it again
  7. Type: reboot
  8. Once your back in, go to System Preference and edit your user accounts. When it asks for the admin’s username and password, enter root and the new password
  9. Logoff and log back in and your set

Hope that helps some of you.