Get a free year on Tuts+ this month when you purchase a Siteground hosting plan from $3.95/mo
A few weeks ago, I showed you how to setup your very own linux server. Now, I'm going to show you how to add even more
Before We Begin...
This guide assumes that you've followed my previous tutorial, How to Setup a Dedicated Web Server for Free, or
that you've got a similar server already set up.
What We're Going to Accomplish
In this tutorial, we're going to:
- Install a Subversion server, so that you can use version control for your projects.
- Add a system management application, more popularly known as Webmin, so that you can keep track of your server's status
and get real-time updates.
A Quick Note
These steps can be accomplished while sitting at the computer and typing into the console, or for those who
like to run a headless server, you may use SSH. I covered it in my previous guide, so if you're unfamiliar with
the technology, head over there to get started using it. Now, without further ado, let's get started!
While there are many version control systems, Subversion is one of the most popular. Subversion allows you to keep multiple versions of your code, allowing you to always revert back if you need a previous version.
Let's download it!
First, you need to login to your server; I'm doing it over SSH, so my screenshots will show my terminal:
Now, type this in and hit enter:
sudo aptitude install subversion
It will ask you for your password; type it in and press enter. Also, it may ask you if you want to continue, press "y" and hit enter.
Your server will now download and install the subversion server:
Once that's done, we need to set it up.
Setting Up Subversion
This next part can be kind of confusing. What we're going to do is create a new group, called "subversion" that will allow the Subversion server to
securely write to your repositories in your web server, but nothing else. To do this, enter the following commands, replacing USERNAME with your actual username.
sudo addgroup subversion sudo usermod -a -G subversion USERNAME sudo usermod -a -G subversion www-data
In order, those commands: add a new group called "subversion," add your user account to the new group, and add the web server's user to the group.
Now, we need to create a place for your repositories. This can technically be put anywhere, but I always store it in /var:
sudo mkdir /var/svn
Finally, create the project folder and repository:
sudo mkdir /var/svn/project sudo svnadmin create /var/svn/project
And give the web server (and anyone in the subversion group) access:
sudo chown -R www-data:subversion /var/svn/project sudo chmod -R 770 /var/svn/project
So far, we've created the subversion group, created a place for our repositories, created a new repository called "project," and given the web server access to this project.
The last thing we need to do is allow Apache to serve the repositories. To do this, we need to install a new Apache library, called libapache2-svn. By now, you should know how to
sudo aptitude install libapache2-svn
After that's done, open up the Apache SVN configuration file:
sudo nano /etc/apache2/mods-available/dav_svn.conf
Scroll all the way to the bottom, and add the following:
<Location /svn> DAV svn SVNParentPath /var/svn SVNListParentPath On AuthType Basic AuthName "Subversion" AuthUserFile /etc/subversion/passwd Require valid-user </Location>
Save the file (Control-O and then enter) and close it (Control-X). (note for Mac and Linux users: regardless of your OS settings, it's still control, not command or super.)
Basically, what happened there was you told Apache that when the URL ends with "/svn", serve up
a list of your subversion repositories which are located in "/var/svn". You then told it that you only
want people listed in "/etc/subversion/passwd" to be able to see these repositories.
Now, to put these changes into effect, reload Apache's configuration:
sudo /etc/init.d/apache2 force-reload
After you've done that, open up your favorite web browser and browse to http://yourserveraddress/svn. It will ask you to login, but no matter what you put, you will get
an internal server error:
Don't worry! This is because we haven't defined any users yet in /etc/subversion/passwd. Let's do that now:
sudo htpasswd -c /etc/subversion/passwd USERNAME
This will create a new entry for USERNAME with the password you specify. PLEASE do NOT use your normal account password as this password is sent insecurely, and in the odd event someone
intercepts it, you don't want them to have root access to your machine. After you've done this, go back to that page (http://yourserveraddress/svn) and refresh it. It should now ask for your username
and password again:
Put them in, and voila! You can now see all of your repositories (in this case, just project) and you're ready to use it for version control!
To add more users, run this command, replacing USERNAME with the new user's username.
sudo htpasswd /etc/subversion/passwd USERNAME
Setting Up Webmin for Server Management
Now that you have this fancy server doing all these different things, wouldn't it be nice to be able to manage it easily? Say hello to Webmin, an awesome web-based front-end for
system configuration, monitoring, etc. It does some pretty sweet things, like sending a text message to your phone if your server goes down. The best part: It's completely free. So, let's install it!
First off, we need to download the latest Webmin debian package off their site. At the time this article was written, the current version is 1.450. So, run this command to download the file:
However, before we can install it, we need to satisfy some dependencies (we need to install programs that Webmin uses):
sudo aptitude install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl
After that has finished, install Webmin using the file we just downloaded:
sudo dpkg -i webmin_1.450_all.deb
Now, let that finish, and once it's done, Webmin has been installed! Open up your favorite web browser, and browse to https://yourserveraddress:10000/ (notice that it's https). You should see the following page: (If it doesn't work, keep reading)
Log in using your normal details; the same details you use to login to the server.
For those of you who can't connect, (likely most of you), read the next section. For those who can, skip the next section.
Hold Up; I Can't Connect!
For those that can't connect, good. It means your firewall is doing it's job. However, in this case, we want access to port 10000, so we need to add a new firewall rule. These directions are explicitly for those who followed my previous guide. Open up your Shorewall rules file:
sudo nano /etc/shorewall/rules
Add this line right above where it says #LAST LINE:
ACCEPT net $FW tcp 10000
Save the file (Control-O and then enter) and close it (Control-X).
For comparison, here is AlexVillmann.com's firewall rules: (I have more rules than the one we're adding, but you get the picture)
Now, restart Shorewall:
sudo /etc/init.d/shorewall restart
Finally, go back to your web browser and browse back to Webmin (https://yourserveraddress:10000/) and it should work this time.
Congratulations! You've got Webmin all set up! There are a million things you can do with it, but all are outside of the scope of this article. Personally, I would just play around with it until it does the things you want it too. It's pretty self-explanitory, and for everything else, there is the Webmin Documentation. Have fun!
By following this guide, you've setup version control and a sweet web management application. I wish I could go into detail about Webmin, but that is an article all by itself. Anyway, I hope this helps you move forward in your linux server adventure!
For those who seek more information on the topics I've covered, here are some great links:
- Subscribe to the NETTUTS RSS Feed for more daily web development tuts and articles.