Ok this will be the first part of the series I promised earlier on. The series will be about my adventures of setting up an Debian Sarge VPS server, a package of Strato Hosting. In this first part I will help you through some of the basics. Which includes structuring your server and setting up the basics for Apache.
Deciding on a structure you like
The first thing you will need to do is decide how you would like to maintain your server. Because this has a huge impact on how you structure the thing. When making the decision you should keep the following in mind:
- Do you like a thousand places for configuration files to be 😉
- How important is it to be able to create backups of entire websites or domains.
- Would you want your logs easy accessible or hard to find
If you are like me you prefer to be all the configuration to be in one place. Grouped per application or service, eg. one directory for Apache config files, one for AWStats, etc. Then it doesn’t matter how many files you create you’l know where to look.
The structure I always pick is something like this:
Easy thing is that I now have all related things together. In multiple ways, per domain (by using symlinks) and per type like configuration, log, etc. Here’s a set up order to do this all.
This will set up all the needed directories for one web project. Creating first the base directories for all the configuration files and logs. After that you create the domain directory and a symbolic link to the log directory.
Creating the initial Apache set-up
Now that you have the base structure of a webserver (or gameserver or whatever you like to call it) you can set up Apache. For me most of this was very simple, as Apache 2.0 already came pre-installed on the server. But if it isn’t you can do it manually by executing the following line:
Note that you may not have to do the first two steps. But it does guarantee Apache 2 can be installed. After executing te second line you should get a listing of all available modules you can install, if you don’t you can’t install Apache 2. The third step actually installs Apache 2. You will probably get a question if you wish to download and install, just reply with ‘Y’.
For now you should not need to modify the main Apache configuration file, we’ll do some of that later on :).
Lets first create an Apache config directory for our personal use:
Now we can create the configuration for our first website:
With the following content:
This configuration will prepare our Apache server to start listening to port 80 for the website www.domain.com, just like we want to. You may notice if you tested the website it doesn’t work just yet.
That’s just about going to be fixed. What you should do next is edit ‘/etc/apache/apache.conf’, or ‘/etc/apache/httpd.conf’. The latter is only for Apache 1.x. Add the following line, which will ensure Apache loads our custom config files:
Now create a file with the following command:
Add the content below. This will enable Apache to listen on port 80 and port 443 (secure socket) as well as enabling the Virtual Host system for port 80.
Now all that is left to do is restart Apache and you’re done for your first website. Restart Apache by running:
Presto a working website! Well at least if you uploaded some HTML pages to the ‘/published/domain.com/wwwroot’ directory that is.
Setting up additional website is a lot easier though. You only need to create a new config file like described in step 2. You can create as many websites as you want as long as they run on port 80. This because this is the only port using the Virtual Host technology.
Well I’ve made this article to long already so let’s wrap it up. I will soon write some more articles on setting up Debian VPS. But if you’ve got a remark or question then leave a comment and I’ll try and help you.