Add Subversion to the XAMPP Apache Server

Windows Development 9 Comments

subversionSubversion is a simple and popular source control system. It has the option of running as part of the Apache server. We’ll examine how to quickly get subversion up and running with the Apache server which comes with XAMPP.

  1. Download the latest subversion windows archive. Look for a file named “svn-win32-1.4.6.zip” (or with a later version number) at the bottom of the list.
  2. Unzip it to a local directory “c:\bin” and you will end up with “c:\bin\svn-win32-1.4.6”.
    • Add “c:\bin\svn-win32-1.4.6\bin” to the end of the Windows “path” environmental variable. This will allow us to run the command line subversion client and repository administration tool.
    • Warning: If you use Eclipse and the SubEclipse plugin, putting subversion in the “path” environmental variable may break the SubEclipse plugin. If this happens, just remove subversion from the “path” environmental variable and use Eclipse to perform subversion functions exclusively. Or ensure that your installed SVN version is compatible with SubEclipse; for example, SVN 1.4.6 is compatible with SubEclipse 1.2.1.
    • Also set “SVN_EDITOR=notepad.exe” to identify the default text editor to be used by the subversion command line tools.
  3. Create an initial blank repository called “svn_repos” by launching the command prompt window and running:
    svnadmin create c:\svn_repos
  4. Configure apache to use the subversion module
    • Stop the Apache server
    • Copy the apache module “c:\bin\svn-win32-1.4.6\bin\mod_dav_svn.so” into the apache modules directory “C:\xampp\apache\modules”. Go ahead and overwrite the existing “mod_dav_svn.so” file as it is from an older version of subversion.
    • Open up the apache config file “C:\xampp\apache\conf\httpd.conf”
    • Enable the subversion module by adding “LoadModule dav_svn_module modules/mod_dav_svn.so” anywhere after the existing “LoadModule dav_module modules/mod_dav.so” line. The best thing would be to add it as the last LoadModule line.
    • At the end, add a URL location (what you would enter into the browser or your subversion client) for your repository:
      <Location /repos>
          DAV svn
          SVNPath c:/svn_repos
      </Location>
    • Start the Apache server
    • You can access the repository using the URL “http://localhost/repos”. You should see a “Revision 0” header with no other data. If you get an error, check the “C:\xampp\apache\logs\error.log” file for details on the problem.
    • Note that you will need to add a location block like the above for each repository that you create with “svnadmin create”. (You shouldn’t need to do this because a repository can contain as many projects as you want.)
    • Note: we have not secured the repository so anyone can read or write to it. To secure subversion, see my followup post.
  5. Import an existing project (source code directory) into the “svn_repos” repository
    • If you have source code in a project directory like “c:\oldprojects\myoldproject”, you can import the contents of “myoldproject” into the subversion “svn_repos” repository by running this command:
      svn import c:\oldprojects\myoldproject http://localhost/repos/myproject -m "Initial import"
    • The comment “-m “Initial import”” is optional. If you don’t input it, the default subversion editor (“notepad.exe”) will appear. Add your import comment and save the file. If you close the file without making any changes, you will need to input “c” into the command prompt window to continue the import.
    • Browse to “http://localhost/repos/myproject” and you should see “Revision 1” header with the list of folders and files that have been imported.
  6. You can create a new empty project by creating an empty folder and importing it (see above).
  7. Checkout the initial “myproject” project to create a local working copy
    • Open the command line and go to the “c:\projects” directory.
    • Check out “myproject” by issuing the following command:
      svn co http://localhost/repos/myproject myproject
    • You will see a “c:\projects\myproject” directory with your imported folders or files (if you did the import step above). If you didn’t import, you will see an empty directory except for a “.svn” subdirectory; don’t touch the “.svn” subdirectory as it is used by the subversion client for bookkeeping.
  8. Inside your local working copy “c:\projects\myproject”, you can issue the following common subversion commands:
    • To update your local working copy with the latest revision from the repository:
      svn update
    • To add a new file:
      svn add newfile.cpp
    • To remove a file:
      svn rm oldfile.cpp
    • To move and/or rename a file:
      svn mv oldfile.cpp subdir/newoldfile.cpp
    • List the changes (aka status) that you have made to your working copy:
      svn st
    • To commit (aka checkin) the local working changes to the repository:
      svn ci -m "my checkin comments"

      If you don’t input the comment using the “-m” flag, the default editor (“notepad.exe”) will open to allow you to input the comment.

  9. To ignore certain subdirectories or files that you do not wish to check into subversion
    • Go to the directory containing the subdirectories or files to be ignored and run this command:
      svn propedit svn:ignore .
    • The default editor (“notepad.exe”) will open. Input the subdirectory and file names, one per line.
    • Instead of putting the exact filename, you can use a file pattern like “*.obj”.
    • Save and close the file.
    • To make this change permanent, issue a “svn ci” command.
    • You can also create a text file “ignore.txt” containing the subdirectory, filenames, and file patterns that you wish subversion to ignore, and apply it recursively to the current and all subfolders by running:
      svn propset -R svn:ignore . -F ignore.txt

Some info above derive from Ned Batchelder: Subversion on Windows quick start.

9 Comments

Setting Up an Apache, MySQL, PHP Development Environment with XAMPP

Windows Development 2 Comments

Rather than installing Apache, MySQL, and PHP individually, XAMPP is an integrated development enironment that combines all three (and more) into one easy installation.

  • Download XAMPP and install it into the default “c:\xampp” directory. Set apache and mysql to start as services.
  • Start XAMPP and browse to “http://localhost/” and you will see a welcome message.
  • If you don’t want to use the default “c:\xampp\htdocs” directory as your document root, you can update the DocumentRoot “C:/xampp/htdocs” property and <Directory “C:/xampp/htdocs”> element in the “c:\xampp\apache\conf\httpd.conf” file. The result should look like:
    DocumentRoot "c:/projects"
    <Directory />
    ... do not change this / default root block...
    </Directory>
    <Directory "c:/projects">
    ...
  • Likewise, if you use SSL, update DocumentRoot “C:/xampp/htdocs”
    in “c:\xampp\apache\conf\extra\http-ssl.conf”.
  • Note: XAMPP uses the “c:\xampp\apache\bin\php.ini” when running PHP. There is a second “c:\xampp\php\php.ini” which is used if you call “c:\xampp\apache\bin\php.exe” from the command line.
  • Edit “c:\xampp\apache\bin\php.ini” to enable logging by setting the following properties:
    error_reporting = E_ALL
    log_errors = On
    error_log = "C:\xampp\apache\logs\phperror.log"
  • To enable access to the original XAMPP htdocs directory, we can create a subpath redirect to it using the alias function.
    1. Edit “c:\xampp\apache\conf\httpd.conf” and locate the <Directory “C:/projects”> block (or whatever path you had selected as document root).
    2. Immediately after the whole <Directory> block above (look for the matching end tag </Directory>), add the following text:
      # Allow access to the original xampp htdocs
      Alias /htdocs C:/xampp/htdocs
      <Directory "C:/xampp/htdocs">
          Options Indexes FollowSymLinks Includes ExecCGI
          AllowOverride All
          Order allow,deny
          Allow from all
      </Directory>
    3. Adjust the htdocs files to account for the base URL change:
      • Edit “c:\xampp\htdocs\index.php”, locate header(‘Location: ‘.$uri.’/xampp/’);, and change that to be header(‘Location: ‘.$uri.’/htdocs/xampp/’);.
      • Repeat the above for “c:\xampp\htdocs\xammp\index.php” and “c:\xampp\htdocs\xampp\lang.php”.
      • Edit “c:\xampp\htdocs\xampp\splash.php”, locate
        <a href=”/xampp/lang.php?’.$key.'”>
        , and change that to be <a href=”/htdocs/xampp/lang.php?’.$key.'”>.
    4. Start XAMPP, open your browser to “http://localhost/htdocs” and you will see the original xampp htdocs directory.
  • If you attempt to access Apache from another machine in your network and your brower returns an access error, you may need to adjust your Windows Firewall. The latest version of Windows Firewall forces you to manually open up ports for services.
    1. Go to Start, Control Panel, Windows Firewall and click on the Advanced tab.
    2. Make sure that “Local Area Connection” is checked and hit the Settings button to the right of it.
    3. Under Services tab, make sure that “Web Server (HTTP)” is checked.
2 Comments