Oct 5 2010
Setting up SubVersion (SVN) on Local Ubuntu with Netbeans
Assuming you have SVN installed follow these steps from the shell (where “proj” is your project). You can put this anywhere you want really, this is how I decided to do it though to keep it out of my default apache directory. I’ll show steps for configuring this to work with apache if you’re doing this as a PHP repo on your localhost. You may need to sudo yourself for these commands. Also, I’m an SVN novice so follow at your own risk. I’m pretty sure I did this poorly…
mkdir /var/svn/proj svnadmin create /var/svn/proj cd /var/svn/proj mkdir trunk branches tags sudo chown -R www-data:subversion /var/svn/proj sudo chmod 774 -R /var/svn/proj
Next import any existing files into SVN. Even if I don’t have any pre-existing code I do this step anyways. If you have any files or directories you want to keep out of the SVN repository (environmental configs, frameworks, logs etc.) then withhold them from the import and add them manually later. When you end up adding these files later, use the NetBeans GUI to set them to ignore otherwise you will have to go through the SVN command line using propset.
svn import /path/to/files file:///var/svn/proj/trunk -m "Initial Import"
The last thing we will want to do is create a directory outside of SVN to checkout the files too and do all our actual work in. I choose to put this in /var/www/svncheckout/proj.
mkdir /var/www/svncheckout/myawesome project
I’ve included a screenshot of the steps I took right on my Ubuntu 10.10. desktop. You can even see the dumb little mistakes I made in there, doh!
The NetBeans Side of Things
In NetBeans perform the following steps.
- Create a new project (File -> New Project). Select your options, I chose PHP and PHP Application with Existing Sources. Click Next.
- Enter in the sources folder /var/www/svncheckout/proj and a project name. Check Next.
- The next window asks you to enter in the project url. Enter in the url you intend on using for the project on your local machine. Click finish.
- Checkout the files from SVN by click in Team -> Subversion -> Checkout in the NetBeans menu.
- Enter in the repository url, file:///var/svn/proj and Click Next.
- Browser the repository folders and select the trunk of your project. Clock OK.
- You just want to checkout the trunks contents so check the Skip option and also check the Export a clean directory option. Make sure you’ve specificied a local folder to checkout to such as /var/www/svncheckout/proj
Here are some screenshots I took of the process:
Creating new project
SVN File Checkout
Now onto the Apache portion cause if you’re like me this is going to be a LAMP project. This is a simple change to /etc/apache2/sites-available/default and a restart of apache. Simply add this to the bottom of the file. Don’t add within an existing virtual host, cause its kind of its own deal.
<VirtualHost *:80> ServerAlias jail.local DocumentRoot /var/www/svncheckout/jail/ </VirtualHost>
Restart apache! One last thing now. Your machine doesn’t really know what proj.localhost is and neither do any DNS servers. So edit your hosts file /etc/hosts and simply add in a line like this:
Okay now we’re really done. Drop me a comment if this helped your or if you feel I missed something, thanks for reading.
** update **
This blog was featured in the Net Beans newsletter…sweet! Love Net Beans!
This blog post has been updated since its original posting. Last updated February 19, 2011.