Top posts

Latest articles


Upgrading my VPS to Debian Etch

Posted by Jongerius under General Rant, Internet
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

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.

  • Make a full backup of any website’s / databases / scripts running (don’t forget your crontab and logrotate files)
  • Copy the backup to a directory not affected by the upgrade. In my VPS the provider has one folder which will be left untouched, but also pull the backup to a local system (just in case ;) )
  • Notify any other users also using your server, don’t want any suprises to potential paying customers.

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:

  1. Un rar the backup of the websites / conf files and scripts (tar xf <tar name>) and move them to the right location.
  2. Setup the proper user account /groups to have access to these files (or your users won’t be able to upload or change the website’s any more)
  3. Install apache / PHP and mysql by running the following command:
      apt-get install php5 mysql5-server apache2 mysqllib
  4. Setup the apache conf file to load in your restored conf files (eg: Include /export/conf/apache/*.conf)
  5. Replace the mysql my.cnf with the one you backed up previously
  6. Enable the rewrite and ssl modules of apache (I forgot and got some upset calls :( )

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.


Setting up logrotation with AWStats

Posted by Jongerius under General Rant
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (1 votes, average: 4.00 out of 6)
Loading ... Loading ...

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.

Setting up the logrotation

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.

The next step is setting up AWStats

Which should not be difficult as it can be done with:

apt-get install awstats

After 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.

Setting up awstats on Apache

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/
Alias /awstats-icon/ /usr/share/awstats/icon/
<Directory /usr/share/awstats/icon>
  Options None
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>
Now you can access the statistics by browsing to http://domain.com/awstats/awstats.pl?config=domain.