Introduction to Linux Server Setup with SVN

Author: Jonathan Hood

This lecture is a demonstration of how to setup an apache/mysql/subversion server using Ubuntu 10.04. When you are done, you will have a server capable of running PHP web sites utilizing a MySQL database. It will also have phpmyadmin installed for managment of the MySQL server. Subversion is used for version control, and is incredibly useful for software projects that are developed by small to medium sized groups.

Lecture Materials

Server Setup Instructions

NOTE: These instructions were developed for use on Ubuntu 10.04 LTS. It may work on other versions of Ubuntu or Debian.
	-- Setup Packages --
	sudo apt-get update
	sudo apt-get install apache2 php5 mysql-server phpmyadmin subversion libapache2-svn libapache2-mod-auth-pam

	-- Setup SSL --
	sudo make-ssl-cert generate-default-snakeoil --force-overwrite
	sudo a2enmod ssl
	sudo a2ensite default-ssl
	sudo /etc/init.d/apache2 restart

	-- At this point, everything is here that is needed for php development
	-- You can upload files using sftp 										
	-- The site root is /var/www by default on debian systems 				

	-- Make your user's public_html the web root directory. Also, give access
	-- to your user. Replace <username> here with the name of your user
	sudo usermod -G www-data <username>
	sudo chown www-data:www-data /var/www/ -R
	sudo chmod g+srw /var/www/ -R
	sudo ln -s /var/www/ /home/ubuntu/public_html

	-- Now, adding files to the public_html directory will add them to your web root --

	-- Lets set up an SVN repository
	sudo mkdir /var/svn/
	sudo svnadmin create /var/svn/project/

	-- Make sure apache can access the repo --
	sudo chown www-data:www-data /var/svn/project/ -R
	sudo chmod o+rw /var/svn/project/ -R

	-- Now, we have to tell apache about the new svn repo --
	sudo a2enmod dav_svn
	sudo pico /etc/apache/mods-available/dav_svn.conf
	
	-- This file is heavily commented. The information
	-- you need to enter is fairly obvious
	
	sudo /etc/init.d/apache2 reload

	-- For authentication, lets use PAM. PAM is the authenticaion
	-- system used by most linux based distributions.
	sudo a2enmod auth_pam
	sudo usermod -G shadow www-data

	-- Again, edit the dav_svn settings
	sudo pico /etc/apache/mods-available/dav_svn.conf
	
	--Add the following to the <Location> tag
	--Again, replace <username> with your user
	AuthPAM_Enabled On
	AuthBasicAuthoritative Off
	AuthType Basic
	AuthName "SVN"
	require valid-user
	require user <username>

	-- Restart --
	/etc/init.d/apache2 restart
	
	-- Your server is now set up. You can now access your repo by going to:
	-- https://your_server_ip_address/svn
	-- And you web site by going to:
	-- http://your_server_ip_address/