Update: this guide is outdated, please refer to Setting up my perfect dev environment on OSX 10.9 using Chef / Kitchenplan for the latest version.
I'm a frequent reinstaller. There I said it. I can get a lot of entertainment by setting up my computer just the way I want it to be. This means that after a few tries i've got this thing covered and it is time to share it with the world. For the record, I'm not going into the process of obtaining and installing OSX, you need an Apple Developer account for that, and if you do have one, you know how to install it.
So, you have go a clean install, now what.
First off, head over to the Apple Developer site and download "Xcode 4.4 Developer Preview 3 for Mountain Lion" and install it. Now, open it up the Xcode preferences, go to 'Downloads' and install the command line tools. This installs stuff like GIT, GCC, etc
We also need to configure some System Preferences. To make the sidebars more pretty, go to General and set the Sidebar Icon Size to small.
In the Dock settings, decrease the size, minimize into the application icon and disable the animation for opening and closing applications.
In Security & Privacy allow running applications from Anywhere. In the future this probalby won't be needed, yet at this point a lot of apps have not been updated. I also disable Location services, because it keeps running at 100% cpu.
As a developer, a lot of time is spent in the terminal. There are a lot of customisations possible that make working here better. Mathias Bynens made a great repository with a whole host of settings on Github. Clone it, read it, fork it and make it your own. So did I and the result you can find on Github as well. I removed some of the settings that did not agree with me, but added others that are needed in my workflow or to work around issues.
To install my version run
git clone https://[email protected]/roderik/dotfiles.git cd dotfiles
Important: Edit the .extra file with your own information and then run
Restart your terminal and be amazed.
Another gem in this dotfiles repo is the .osx file. It's full of settings that improve OSX for the developer. More info via Lifehacker. Just run:
In a lot of guides you will find a section telling you to install iTerm2, since i have never found anything lacking from the native Terminal.app, i just use the default. There is only one thing that is missing, and that is a global hotkey to open the Terminal.
That's a job for Alfred. Using the Powerpack extension you can add global hotkeys. Add Terminal.app like so:
To install all kinds of open-source applications like database servers etcetera, we need a decent package manager. The best one for OSX is Homebrew. Install it by running:
/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)" brew update
Mountain Lion removed X11 from the installation, you need to install the version from XQuartz
Now, let's install a package. Important to note that all these commands are executed as your own user!
brew install git bash-completion git
bash-completion will help you along with completing commands, link git, or homebrew commands. Always read the notices after installing a package from Homebrew, since extra installation steps are described there. For example for Homebrew:
Add the following lines to your ~/.bash_profile file: if [ -f `brew --prefix`/etc/bash_completion ]; then . `brew --prefix`/etc/bash_completion fi To install Homebrew's own completion script: ln -s "/usr/local/Library/Contributions/brew_bash_completion.sh" "/usr/local/etc/bash_completion.d"
Now the first one is included in my dotfiles, the last was you still need to execute.
I always install GIT from Homebrew to get the latest and greatest. Don't worry more packages will follow.
Next up, we need a text editor with some punch, depending on your taste ofcourse. I like Sublime Text 2, download, install and enter your registration info. We will set this up following parts of Stuart Herberts guide for Sublime Text 2 and PHP
You first need to install Will Bond’s Package Control (installation instructions). Package Control is a plugin that automates the job of installing and upgrading plugins. After you’ve installed it, restart ST2, and then you’ll find a new “Package Control” menu option at the bottom of the “Preferences” menu.
Using Package Control, install the ‘Soda’ Theme plugin and the Phix Color Scheme. Open up the ‘Settings – User’ preferences file (this is a JSON file), and add the following to tell ST2 to use the new theme:
"theme": "Soda Dark.sublime-theme",
Follow along with this video to do this:
If you are into PHP programming in a text editor and not in an IDE, follow the rest of his guide. I will move along to Trailing whitespaces. They are annoying but ST2 can remove them on save.
One step left, installing the commandline addon.
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
I've got a love-hate relationship with Ruby. Lots of great tools are written in Ruby, yet it's a mess to install with all the different versions and gems. There are a few projects geared toward easing this, where I feel rbenv is the most suited.
rbenv lets you easily switch between multiple versions of Ruby. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.
Let's install it:
cd git clone git://github.com/sstephenson/rbenv.git .rbenv echo 'eval "$(rbenv init -)"' >> ~/.extra source ~/.bashrc mkdir -p ~/.rbenv/plugins cd ~/.rbenv/plugins git clone git://github.com/sstephenson/ruby-build.git
You can now install Ruby 1.9.3-p194 and setting it as default by running the following. Afterwards, test if it worked by opening a new Terminal window and running ruby -v
rbenv install 1.9.3-p194 rbenv global 1.9.3-p194 cat "rbenv global 1.9.3-p194" >> .extra
For my development I make use of mySQL, Postgresql. Let's start by installing mySQL from Homebrew
brew install mysql unset TMPDIR mysql\_install\_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp mkdir -p ~/Library/LaunchAgents cp /usr/local/Cellar/mysql/5.5.20/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist /usr/local/Cellar/mysql/5.5.20/bin/mysql_secure_installation
Now let's move on to Postgresql. Under 10.8 there is an error while compiling some module. If you compile using -dv you get a recovery console, by just typing exit, it will finish installing. Until now I have had no problems with the result, so the error is probably in some plugin that I do not use.
brew install -dv postgresql
You need to create the database and set it to run by default by running
initdb --locale=en_US.UTF-8 --encoding=UTF8 /usr/local/var/postgres
No plist file is created due to this compile error, but since I do not use postgres often I can make due with the alias that is created in the dotfiles.
The PHP installed in 10.8 is 5.3.10. Although I always want the latest and the greatest, I normally would have installed 5.4 from the php-osx project. I tried Homebrew and compiling by hand, too much hassle.
So, we will just have to work with the preinstalled version.
Let's start with install pear, apc and xdebug.
sudo cp /private/etc/php.ini.default /private/etc/php.ini sudo php /usr/lib/php/install-pear-nozlib.phar pear config-set php_ini /private/etc/php.ini pecl config-set php_ini /private/etc/php.ini sudo pear upgrade-all
sudo pecl install apc sudo pecl install xdebug
Now pecl install adds xdebug as extension, and it needs to be a zend_extension. Open /etc/php.ini and chenge the xdebug line at the top to
Now we need the intl extension for Symfony 2
brew install icu4c wget http://www.php.net/get/php-5.3.10.tar.bz2/from/this/mirror tar vxjf php-5.3.10.tar.bz2 cd php-5.3.10/ext/intl phpize ./configure --enable-intl --with-icu-dir=/usr/local/Cellar/icu4c/188.8.131.52/ make sudo cp modules/intl.so /usr/lib/php/extensions/no-debug-non-zts-20090626/
Add the following to /etc/php.ini
And now the gettext extension
brew install gettext cd php-5.3.10/ext/gettext phpize ./configure --with-gettext=/usr/local/Cellar/gettext/0.18.1.1 make sudo cp modules/gettext.so /usr/lib/php/extensions/no-debug-non-zts-20090626/
Add the following to /etc/php.ini
Change the php.ini to look like this
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Europe/Brussels
In php.ini, you need to replace all /var/mysql/mysql.sock by /tmp/mysql.sock so php can connect to our mySQL version.
That's it, probably there will be some small updates in the following days, i'll keep you posted. If you have any suggestions or remarks, please let me know in the comments.