One of the things I like about working on OSX as a development platform is the flexibility I have in choosing tools and development environments to work in. My favorite environments in the past have been OS/2 and Linux environments. I’ve done a fair amount of work in AIX, HP-UX and mainframe.
OSX Lion comes with many different tools built in. There is g++, svn and apache2 that are all built in. Under the covers, OSX is BSD Unix, so it is very similar to Linux. Some of the library locations are different, but they all roll up to the same product functionality across platforms.
Since I spent 2 1/2 years working for IBM marketing Eclipse, I tend to favor Eclipse as my favorite development platform.
So, here is how I set up my development environment on OSX Lion. I wanted to use my Mac Pro as my main development environment, and make this available to my MacBook and to other trusted resources.
First, let’s get Subversion working through the built in Apache server.
Go into System Preferences panel from the Apple menu, then open the Sharing folder from the Internet & Wireless section. See the service that says “Web Sharing”? That’s where you start and stop the Apache server. Click “On” to turn on the Apache server. (If you want to have fun, this is also where you can install local copies of WordPress, Joomla, Vanilla and a number of Apache based projects. Perhaps in another blog post…)
Time for the terminal window!
Go into Applications -> Utilities and open the Terminal application
First, we’ll create the password file to protect the subversion repository. We plan to open this up to others over the internet, but keep it under security since this is for a private project. If you want to open it to the world, first consider using GIT or one of the many public code sharing sites. Otherwise, skip the security steps outlined below.
Create the password file for Apache access to subversion
In the terminal window, type the following lines
cd /etc/apache2/extra/
htpasswd -cm svn-password.pass username1 //substitute user name for username1 and enter a password
htpasswd -m svn-password.pass username2 //append another username and password until complete
Create the subversion repository
sudo -s //log on as root user. Enter your password.
cd /usr/local //we'll create the repository in usr/local
mkdir svnrepos //create the repository directory
svnadmin create repo //create the actual repository
cd /etc/apache2/extra/ //directory to hold svn repository info for Apache
nano httpd-subversion.conf //NEW configuration file to be added to Apache httpd.conf
Enter the following text into the newly created file
LoadModule dav_svn_module libexec/apache2/mod_dav_svn.so
LoadModule authz_svn_module libexec/apache2/mod_authz_svn.so
DAV svn
SVNPath /usr/local/svnrepos/repo
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/extra/svn-password.pass
Require valid-user
If you are new to nano, the way you save files is to type control-O (not command-o) to output the file. At the bottom of the editor, it will ask you the file name, which we’ve already determined as “httpd-subversion.conf”. Hit “enter” then press control-x to exit.
Next, edit the Apache configuration file to include the above information
nano /etc/apache2/httpd.conf
Page down a couple of pages until you see various “includes” and add the following two lines:
# Subversion
Include /private/etc/apache2/extra/httpd-subversion.conf
Finally, set the permissions
sudo chown -R www:www /usr/local/svnrepos/
Now we need to restart the Apache server. From the Apple menu, System Preferences, Sharing, click off “Web Sharing”, then click it back on. If you want to stay in the command line, I’m sure you can Google the commands to restart apache from the command line.
Test the installation
Let’s put something in the repository so we can test.
cd /usr/local/svnrepos/
mkdir tmp
svn co file:///usr/local/svnrepos/repo //you should get a return notice "checked out revision 0"
To test the SVN installation, go to http://localhost/repo
Next, I downloaded the latest version of the Eclipse C/C++ environment. This will appear in your Downloads directory. I prefer to access the Eclipse folder from my Applications, so I drag the Eclipse folder from the Downloads directory in Finder to the Applications folder.
Open Eclipse, and let it initialize. Give it a working directory for the workspace. I usually create one in Documents/eclipse-workspace. Once you are in Eclipse, perform the following:
Help -> Install New Software
Enter the following URL in the “Work with:” field -> http://subclipse.tigris.org/update_1.6.x then click Add.
It will ask you what you want to call it. I called it “Subversion client for Eclipse (Subclipse)”. Click OK.
Choose ALL THREE ITEMS (Select All) and click next, agree to the license agreements, then click Finish.
Important next step for LION
JavaHL is the default for Eclipse to talk to the subversion repository. However, this is installed in 32-bit and since this is Lion it needs to be 64-bit. There are work arounds for making JavaHL work by downloading new installations of subversions and playing around with configurations, but I like to keep life simple. There is another option in Eclipse that will get you going.
Eclipse -> Preferences -> Team -> SVN
Highlight the SVN option. Towards the bottom of the panel, you will see “SVN Interface”. Change this from JavaHL to SVNKit. Click OK.
Now you can start using subversion in a secure manner using Eclipse.
Window -> Open Perspective -> Other… Choose “SVN Repository Exploring” and then OK.
Enter the URL we tested with earlier (http://localhost/repo).
Have fun!