Fix apache after upgrading to Mountain Lion

Every time I upgrade OS X something breaks with apache or php or both.

The steps for me to fix it this time was…

* Open your httpd.conf file
* uncomment the Load php5 module
* uncomment the load vhosts module

in etc/apache2/users

* duplicate Guest.conf to harrybailey.conf – replace harrybailey with your username obviously
* edit harrybailey.conf to read:

<Directory "/Users/harrybailey/Sites/">
    Options Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Note: as Michal mentions below you may want to add +FollowSymLinks to your options too. This allows the system to follow any symbolic links you have set up.

AGAIN – replace harrybailey with your username.

* save the file

You may also get a php error which includes…

“It is not safe to rely on the system’s timezone settings”

The fix for that is
* navigate to /etc/ and rename php.ini.default to php.ini
* edit your new php.ini file – find “;date.timezone = ” (no brackets)
* update it to read “date.timezone = Europe/London” (no brackets) – if you aren’t on GMT then find your relevant timezone string and use that
* save the file

* open terminal
* submit the line:
sudo apachectl restart

That did it for me. Hopefully it will do it for you too.

I was first seeing the default html file in the /Library/Webserver/Documents folder
I was then seeing 403 errors for all vhosts that I has setup
Personally I saw these problems after upgrading from Lion (10.7) to Mountain Lion (10.8)

Export structure and data from Navicat Premium as SQL

I was trying to find the quickest way to export both structure and data from all tables of a database from Navicat Premium and came up with these steps:

* Use the backup tool to create a backup of your database
* Right click the backup and select to Extract SQL…
* Save to wherever you like

You can now use that .sql file to create a new database wherever you like.

My current local development setup

Thought it was worth sharing my current local development setup. I run on mac, currently Lion 10.7.4 and these are the pieces of software I used…

Terminal
Used to run Git version control commands. If you’re going to do it, do it properly.

Sublime Text 2
If you take handcoding seriously, ditch your coda, your skEdit, your text wrangler etc, take a weekend installing and tweaking Sublime Text 2 and never look back.
Plugins, amazing autocomplete, unlimited flexability from highlighting to layout, projects, global find, powerful search, need I go on. Beautiful.

Transmit
Superb FTP client from Panic. Don’t edit live code. Download it, run a local site, update it and then use a purpose build ftp client to get the update online. No stupid mistakes.

Sequel Pro
A powerful and free MySql tool. Lots of nice touches like edit in pop-up, tabbed browsing and nice export tools.

LiveReload
Update the preview in your browser without reloading it manually. Instant for css and js, and almost instant for html, php etc. Saves a lot of cmd-R ing.

Google Chrome
Still my the browser of choice after 2 years. Great for dev work with inspector (cmd-alt-i)

FirefoxNightly
Firefox is crap, but it’s new responsive design tools can come in handy for mobile web development. Development software, so use at your own risk.

Others worth a mention…

I also use skitch for screen capture, dropbox for file sharing, Parallels for those times when you have to test windows browsers.

Enjoy and let me know what you think in the comments…

Move your Sites folder in OS X with a SymLink NOT an Alias

Two hours of my life were wasted on this one, even though I’ve done it before. So…

If you want to move your ~/Sites folder into say Dropbox or AeroFS or Google Drive or SkyDrive and then you still want to point to it from its default location don’t use an alias.

I know an alias is only a ctrl-click away, but it means all sorts of pain.

Instead, move the folder to dropbox by dragging it (yes you can do this), then open Terminal and type:

ln -s ~/Dropbox/Sites ~/Sites

Replace Dropbox with whatever the folder of your service is called.

Restart Apache either by restarting Web Sharing in System Preference -> Sharing or by using Terminal and typing:

apachectl graceful

Cross your fingers and open a virtual host in your web browser. I fought with an Alias and all sorts of folder settings and httpd.conf lines to try and get it working, and then all I needed was to use a SymLink in its place.

Don’t worry about no longer having a ‘real’ ~/Sites folder. You don’t actually need one.

Cheers to James Galley, my desk neighbour for helping my brain to click on this one.

Replace Spotlight With Alfred App

If you own a Mac and you haven’t heard of Alfred App then you’ve likely been living in a bunker for a while.

At very least Alfred allows you to quickly start applications. If you choose to delve deeper you can use it to search and open files, run applescripts, quick jump to webpage searches, send emails, control iTunes and 999 other clever tricks.

When you first get your Mac you will likely have heard of Spotlight, a built in application that can be used to search applications and files. It’s hotkey is cmd-space. It isn’t as flexible as Alfred App but it has the best hotkey combination going.

Before we start if you’ve turned off Alfred’s menu bar icon, turn it back on in Alfred appearance preferences. It’s makes for the easiest method of opening during hotkey move.

Here is how to move Alfred App to use cmd-space and Spotlight to use ctrl-space:

System Preferences -> Keyboard -> Keyboard Shortcuts

spotlight keyboard shortcuts

1) In the left column click Spotlight.
2) In the right column click the current key combination for spotlight of ⌘Space (cmd-space) and input your replacement key combination. I recommend ^Space (ctrl-space) although some other applications occasionally reserve it (such as Things App). At this point if you can see it you could also switch the second hotkey combination over to ⌥^Space (alt-ctrl-space).
3) Don’t worry about remembering the old hotkeys. If you change your mind later as you can click Restore Defaults to undo your changes.

You can close system preferences now.

So we’ve moved Spotlight, but now we need to move Alfred to ⌘Space (cmd-space).

Click on Alfred’s top hat menu bar icon and select preferences. (you may need to restart Alfred at this point for it to recognise that you’ve moved Spotlight to a new hotkey.

Choose General and you should see a large box Alfred Hotkey box. Click it and press our new hotkey for Alfred App.
⌘Space (cmd-space)

Alfred Preferences

And that’s it. You should now see Spotlight when you hit ^Space (ctrl-space) and Alfred when you click ⌘Space (cmd-space).