My last post was for all users, technical and non. This post is for the techies who know me, and are switching. Some are coming from Windows, some from Linux, some are designers who need to do some local development. So, I’ll try to keep this post as simple as possible, and perhaps more like a tutorial, where you can “copy and paste” commands and files.
If you’re going to be doing any kind of web development, chances are you’ll be deploying to a linux/unix server. I don’t know anything about Windows or IIS, so ignore this post if you’re looking for IIS help. I’m also assuming basic level of knowledge with how to find and edit files either via Finder, or via Terminal. For the non unix folks ~ for the rest of the article, means “Your home directory” . Your home directory is usually /Users/yourusername
If you’re doing this on a laptop, please keep your company, or your clients security and confidentiality in mind. Disable auto login, use strong passwords, enable computer locking via Keychain.
I use these settings as a base. You can and should do a little more, but that’s not the focus of this post.
Things you’ll need
- XAMPP I prefer it over MAMP, because it seems to get upgraded faster, so the chances of a more recent PHP version are higher. Of course, for the uber nerds, you can get Macports, or Fink. If you’re comfortable, you can even install the Dev Tools CD, get GCC, and compile things yourself, something I used to do, but I no longer need the cutting edge.
- When I feel like getting cutting edge, I do install Vmware Fusion , turn on a Linux image, and have fun.
- Expandrive This is more for production, and remote servers, but I find this tool ridiculously handy. It’s better than the free variant of Macfuse, so it’s worth the money. Here’s how it’s better: the way to manage the drives is simpler, and reconnects to remote drives are more stable than the free sshfs variant.
- You can get MAMP and MAMP Pro MAMP Pro is worth the upgrade, if you decide to get MAMP.
- MySQL If you need MySQL 5.1, or for some reason 4 or 3, you need to go get it yourself, but XAMPP offers MySQL 5.0 by default
- Textmate An excellent editor if you don’t like vim/emacs.
- MacVim This is gVim for mac, with all the mac keyboard bindings, and the power of vim. (this is subjective: and the ease of vim). I’ve replaced the default vim, with this for my personal use
- Subversion 1.5 By default, OS X comes with SVN 1.4, some of my repositories have been upgraded to 1.5 so I needed to upgrade
- Git I’ve been playing on some projects which aren’t live, but merely proof of concepts, and I decided to learn git, with those projects. I’m really digging it, though I’m still struggling with Braid and getting it to do things like SVN Externals.
- Versions App This is a nice GUI for SVN, if you’re into GUIs
Setting up your Shell
Most of these things will go into ~/.bash_profile
Set your editors
Open up ~/.bash_profile in your favorite editor, and add the following lines
Of course, you can replace vim, with emacs, pico, nano, or if you hate your life, ed.
Change your paths
Since we’ve downloaded XAMPP, macvim, Subversion and Git, we need to make sure the newer version of these apps is available to us.
I prefer to move the older binaries out of the way.
Open a new shell and type which php , or which svn
if you see things like /usr/bin/php or /usr/bin/svn, it means you’re still using the older versions. So do the following: (# bash represents your bash prompt, not a comment)
# cd /usr/bin
# sudo mkdir old
# sudo mv php* old
# sudo mv svn* old
You need to do some other things with Macvim, email me if their install instructions aren’t clear to you.
Setup your virtual hosts, and hosts file
Since you’re doing web development, you need to setup apache, and a means to access the virtual hosts on your laptop. Since you’re using XAMPP, you need to make sure that the built in Apache is not turned on. Go to System Preferences -> Sharing and make sure Web Sharing is not checked
The easy, but expensive way
You can download VirtualHost X and manage your virtual hosts with that, but the app is fairly basic, you still need to know your custom directives, if you want to do anything advanced. What’s nice is that it edits your /etc/hosts file for you, so it’s all done in one step. It’s not as advanced as MAMP Pro. But, it’s fairly straightforward and flexible as a GUI.
The somewhat harder, but cheaper way
Since we’re using XAMPP, you need to do the following:
# sudo vim /Applications/xampp/etc/httpd.conf : and uncomment the line asking for httpd-vhosts.conf
# sudo vim /Applications/xampp/etc/extra/httpd-vhosts.conf
Here you can create your own virtual hosts. I use a naming convention of laptop.domain.com, which always points to 127.0.0.1. You could edit your Name servers and add that record, but then it doesn’t work if you don’t have an internet connection. So, I prefer editing my /etc/hosts file.
Example Virtual Host Configuration
#Local Symfony installation for website
< VirtualHost *>
Options Indexes FollowSymLinks MultiViews
allow from all
Alias /sf /Users/vluther/websites/example/lib/vendor/symfony/data/web/sf
CustomLog /var/log/apache2/example_access.log combined
Notice I keep the logs in /var/log/apache2/. This is so I don’t need to mess with the log rotation scripts of OS X.
Example /etc/hosts file
127.0.0.1 laptop.example.com example
127.0.0.1 laptop.example2.com example2
I’m not going into details of how you create your local working copies with git, svn, or finder. If you really need help with that, email me, or ping me on twitter
If you’re using Django, or RoR, you can skip most of the apache configuration options, and just use the built in web servers that come with the frameworks. For production/stage testing I recommend installing linux on a vmware image, and then messing with FastCGI/mod_python for Django or whatever you need to do with ruby.
By no means is this supposed to be the only way you do things, there’s more than one way to skin this cat. Please share your insights and methods in the comments below.