2014/03/20: My Linux Server Setup

Yes, I do have a small Linux server at home that serves files in my local network and which I use for staging my public web site, etc. This article serves to document what I have done and hopefully when I migrate at some time allows me to reconstruct most of my setup. The machine is using Ubuntu 13.10.

Keywords: linux, ubuntu, apache, public html, user site


Apache

First my apache setup (apache is installed with sudo apt-get install apache2. I also want to support user directories which are enabled with the a2enmod command. No fiddling around with configuration files etc. This command sets all the necessary sym links in the respective apache configuration directories.

$ a2enmod userdir

If you ever get tired, a2dismod is the counterpart.

When you are done changing your configuration, do not forget to restart your Apache server with the following command:

service apache2 restart

WebDAV

WebDAV is a remote file system based on HTTP. Installation is simple, just type:

$ sudo apt-get install davfs2

To mount a WebDAV filesystem, add the following line to your /etc/fstab file:

http://address.of.your.server/  /mnt/mydir  davfs  defaults  0  0

And put the credentials for accessing WebDAV into the global secrets file in /etc/davfs2/secrets:

/mnt/mydir  username  password

If you want to mount the WebDAV filesystem as ordinary user, secrets can be place into ~/.davfs2/secrets as well.

Subversion Server

We want a subversion server accesible locally through the file protocol and rremotely through the svn+ssh protocol. This setup has the advantage that we do not need an additional server and ssh is used for authenticating to our svn repository. If we have ssh already running anyway, that means no extra server available to the public. First, we install the subversion server with sudo apt-get install subversion.

Next, we need to choose a directory for our subversion directory which is /home/services/svn in the following example and create the repository:

$ sudo mkdir /home/services/svn
$ sudo chown "$(id -un):$(id -gn)" /home/services/svn
$ svnadmin create /home/services/svn

The above setup assumes that only the current user wants to access the newly created subversion directory. If you have multiple users that need to access the directory, you need to create a common group for all these users and make the above directory group writable. Additionally, you may want to set the sticky bit that newly created entries automatically belong to the shared group.

Next, let's import a directory into our newly created svn repository.

$ svn import myproject file:///home/services/svn/myproject

Note, that the just imported directory, is not automatically added to svn control. For that you need to check it out again or check the manual page whether there is a command line option for that.

There is a nice document of how to limit subversion access here. Creating a dedicated key for use with subversion for yourself, might be interesting as you will have to guard that key as much as your other key with which you would normally login to your account.

if you are using a different ssh key, you want to set the SVN_SSH environment variable as follows:

$ export SVN_SSH="ssh -i /home/tom/.ssh/id_svn_rsa"

Now, you are all set to check out your repositories with:

$ svn co svn+ssh://athena/home/services/svn/myproject myproject

Thomas Gschwind