2009
09.16
  1. Add your favorite mirror to an apt-source file:


    for Ubuntu Jaunty:

    echo "deb http://cran.nedmirror.nl/bin/linux/ubuntu jaunty/" \
    > /etc/apt/sources.list.d/cran.list

    for Ubuntu Intrepid:

    echo "deb http://cran.nedmirror.nl/bin/linux/ubuntu intrepid/" \
    > /etc/apt/sources.list.d/cran.list

    for Ubuntu Hardy:

    echo "deb http://cran.nedmirror.nl/bin/linux/ubuntu hardy/" \
    > /etc/apt/sources.list.d/cran.list

    for Ubuntu Dapper:

    echo "deb http://cran.nedmirror.nl/bin/linux/ubuntu dapper/" \
    > /etc/apt/sources.list.d/cran.list
  2. Import the gpg key:
    gpg --keyserver subkeys.pgp.net --recv-key E2A11821
    gpg -a --export E2A11821 | sudo apt-key add -
  3. Update apt:
    sudo apt-get update
    sudo apt-get upgrade
  4. Install r:
    sudo apt-get install r-base
    sudo apt-get install r-base-dev

References:

  1. Ubuntu packages for R
2009
09.15

Of course the first thing to do is installing awstats:

yum install awstats

After that, I create a symlink from awstats.pl to my cgi-bin.

ln -s /usr/share/awstats/wwwroot/cgi-bin/awstats.pl \
/var/www/vhost/domain/subdomain/cgi-bin/

Then I make sure that Apache allows symlinks:

<directory "/var/www/vhost/domain/subdomain/cgi-bin">
	Options FollowSymLinks
</directory>

Furthermore we need to add a few aliases

Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/share/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"

Now let’s configure awstats. Awstats configuration files are in /etc/awstats. Create a new configuration file (awstats.subdomain.domain.conf) and pay attention for these parameters:

LogFile="/var/www/vhost/domain/subdomain/log/access.log"
SiteDomain="subdomain.domain"
HostAliases="subdomain.domain"

Now we can run awstats by invoking:

perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl \
-config=subdomain.domain -update

Awstats will now analyze our logfile. You should see something like:

Create/Update database for config "/etc/awstats/awstats.subdomain.domain.conf" by AWStats version 6.9 (build 1.925)
From data in log file "/var/www/vhost/domain/subdomain/access.log"...
Phase 1 : First bypass old records, searching new record...
Direct access after last parsed record (after line 117)
Jumped lines in file: 117
Found 117 already parsed records.
Parsed lines in file: 0
Found 0 dropped records,
Found 0 corrupted records,
Found 0 old records,
Found 0 new qualified records.

You should have a working awstats now. Access http://subdomain.domain/cgi-bin/awstats.pl?config=subdomain.domain to verify this.

Finaly, we can make our life a little bit easier by using a tool called AWStats Totals. This tool will (automatically) summarize for which domains we have generated statistics and make those available to us.

Installing AWStats Totals is really easy. The only thing you have to do is download it

cd /var/www/vhost/domain/subdomain/public_html
wget http://www.telartis.nl/files/awstatstotals.zip

unzip it

unzip awstatstotals.zip

put it in place

mv awstatstotals/awstatstotals.php .
rm -R awstatstotals __MACOSX

What I do next is symlink it

ln -s awstatstotals.php index.php

Now, we should see a nice summary when we access http://subdomain.domain/index.php.

2009
09.15

In the default configuration of Apache, any page will contain a full signature of the server. Server signatures contain valuable information about installed software and can be read (and exploited) by worms and hackers. Therefore is it safer to turn off this behavior. This is how you do it:

Open Apache’s configuration file (httpd.conf or apache2.conf) and search for ServerSignature

ServerSignature can be set to On, Off or EMail. Set it to Off.

After that search for ServerTokens

ServerTokens can be set to:

  • Prod (Server: Apache)
  • Min (Server: Apache/1.3.0)
  • OS (Server: Apache/1.3.0 (Unix))
  • Full (Apache/1.3.0 (Unix) PHP/3.0 MyMod/1.2)

Set it to Prod, as you can see this reveals the least information.

If you use PHP on your webserver, another thing you can do is telling PHP not to show it’s version. To accomplish this, open PHP’s configuration file (php.ini), search for expose_php and set it Off.

Obvious, after making these changes, we have to reload Apache. On a Red Hat / CentOS machine we do this by invoking

service httpd reload

On a Ubuntu / Debian machine we do this by invoking

/etc/init.d/apache2 reload
2009
09.15

If you happen to forget the root password or discover that for some reason you are unable to login, then you can make use of the --skip-grant-tables option of MySQL. This is how you use it:

First you have to stop MySQL

/etc/init.d/mysqld stop

Then you start MySQL with the --skip-grant-tables option

/usr/libexec/mysqld --skip-grant-tables

After that, use the MySQL client

mysql>

to execute the following queries:

UPDATE mysql.user SET Password=PASSWORD('####') WHERE User='root';
FLUSH PRIVILEGES;
2009
09.13

The numbers 1, 2, 3, … form the set of positive integers

\left \{ 1,2,3,\ldots \right \}

The numbers …, -3, -2, -1 form the set of negative integers

\left \{ \ldots,-3,-2,-1 \right \}

The set of integers consists of the set of positive integers, the set of negative integers and 0

\left \{ \ldots,-3,-2,-1,0,1,2,3,\ldots \right \}

The set of rational numbers consists of the numbers that can be written as a quotient of two integers \frac{p}{q} where p and q are integers and q \neq 0. We cannot divide by zero. All integers are rational; 2 is because 2 = \frac{2}{1}

Rational numbers can be represented by decimal number that terminate (e.g. \frac{3}{4} = 0.75), or by nonterminating repeating decimals (e.g. \frac{2}{3} = 0.666\ldots). Numbers that are represented by nonterminating nonrepeating decimals are called irrational numbers. An irrational numbers cannot be written as an integer divided by an integer (e.g. \pi, \sqrt{2}). Together, the rational numbers and the irrational numbers form the set of real numbers.