You might have noticed it yesterday, or not
. But my blog and several other websites hosted by me went offline yesterday for a couple of hours. Well this had to do with me upgrading the VPS to Debian Etch.
So far I ran every website on Debian Sarge, and though it’s stable they choose to no longer developer for it nor support it. So it was time to move to a newer version. Wich I did yesterday. Here’s some of the steps you should take before upgrading to the next version of Debian.
I was lucky that my hosting provider offers an easy way to upgrade or reinstall a Linux distro on the VPS. Just a couple of mouse clicks and they prepare the VPS for the installation. Please note that this will take up to an hour to complete. Once this base installation is complete you will want to perform the following steps:
From this point on your ready to go. All of the websites should be running without any problems. You do need to configure any other tools you had installed, like AWStats / Subversion or anything else. Though these should not require to much configuration as all of the configuration files where included in your backup. At least if you followed a setup similar to my first article on setting up linux.
One of the first things I did on my new server was setting up log rotation and AWStats. You may be wondering why. Well its easy, logs tend to grow. And I prefer to have a daily log for Apache projects, rather then one large file for the entire time of running.
By default most servers have this build in. It’s a program called logrotate, which is pretty handy. It consists out of one general configuration file (/etc/logrotate.conf) and several smaller ones (/etc/logrotate.d/*).
I have added my Apache log rotation configuration to the /etc/logrotate.d/Apache file. What you need to do is set how often and what location to perform the log rotation on. The second thing you can set is steps that must be performed before and after the log rotation, which will come in handy later on.
Add something similar to the following for each website:
/export/log/domain.com/*.log {
daily
missingok
rotate 100
compress
notifempty
create 640 root adm
sharedscripts
prerotate
/usr/lib/cgi-bin/awstats.pl -config=domain -update
cd /export/log/domain.com/
endscript
}These settings will rotate the log files once a day, saving up to 100 files maximum. The notifempty setting makes sure empty files never get rotated and missingok prevents the thing from crashing if files are missing. The part between prerotate and endscript I will explain a bit later on, so be patient.
Which should not be difficult as it can be done with:
apt-get install awstatsAfter this easy step you are going to need to configure it per project, which is not so easy. You will need to copy a default configuration file. This is located in /etc/awstats/ and called awstats.conf.
Copy this for each log file you wish to keep statistics of. The file names are to be like:
awstats.<project>.conf
If you’ve done this then all you need to do is change the LogFile location to the location of your apache file. And set the LogType=w to the file for indicating a website. And set the SiteDomain to the name you want AwStats to display.
Keep in mind that you should not change the location of the configuration files, since this will crash AwStats. Also make sure that the project name you choose is identical to the domain name set up in the log rotate step with -domain.
Now that the log files are being processed by AwStats it’s time to make them available through apache. To do that you will need to add the following to the VirtualHost in httpd.conf.
ScriptAlias /awstats/ /usr/lib/cgi-bin/Now you can access the statistics by browsing to http://domain.com/awstats/awstats.pl?config=domain.
Alias /awstats-icon/ /usr/share/awstats/icon/
<Directory /usr/share/awstats/icon>
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>