nginx server status page and interpretation

Server tuning starts with server monitoring, with server-stats you can learn about the usage of nginx.

First, check if nginx has been compiled with –with-http_stub_status_module.

$ /usr/sbin/nginx -V 2>&1 | grep --color with-http_stub_status_module

Check the output for –with-http_stub_status_module. If it’s not there, you must compile it in manually.

If you have it, start by add this config snippet to your server config:

server {
  location /server-status {
    stub_status on;
    access_log off;
    deny all;

Then, reload nginx. You can query the status page from localhost only with this config. Try it:

$ wget -qO -

Active connections: 4
server accepts handled requests
488803 488803 1002230
Reading: 0 Writing: 2 Waiting: 2

This reads like this:

We have 4 active connections, 2 of them are currently being served by nginx (Writing), 0 are requesting something (Reading) and 2 have open connections but there is no activity at the moment (Waiting), this is because of keep-alive connections.

The server has accepted 488803 connections and could answer 488803 of it (100%). Within this connections, 1002230 requests have been served (2.05 requests/connection).

cleanly install the MongoDB driver for PHP


Using MongoDB with PHP on Debian Wheezy doesn’t work out of the box. Here’s how I got it working:

First, install a whole lot of packages and then build the mongo driver: (we remove the unused packages later)

$ sudo apt-get install php5-dev php5-cli php-pear make
$ sudo pecl install mongo

As soon as this is completed, add the driver to PHP. According to your installation, you want to add it to /etc/php5/fpm/php.ini, if using PHP-FPM, or /etc/php5/apache2/php.ini if using apache2 and so on. However, add this line to the config file:

And then, restart the affected services, for PHP-FPM do this:

$ sudo service php5-fpm restart

And for pure Apache, do this:

$ sudo service apache2 restart

If this is on a production server, I recommend to remove all the unnecessary software, especially the compilers:

$ sudo apt-get purge autoconf autotools-dev automake binutils cpp gcc libc-dev-bin linux-libc-dev libc6-dev zlib1g-dev libltdl-dev libssl-dev libssl-doc manpages-dev php5-dev binutils libtool gcc-4.7 cpp-4.7

Then start MongoDB, e.g. like so:

mongod --dbpath /data/test

And for testing, here’s some PHP code from the MongoDB tutorial:

// connect
$m = new MongoClient();
// select a database
$db = $m->comedy;
// select a collection (analogous to a relational database's table)
$collection = $db->cartoons;
// add a record
$document = array( "title" => "Calvin and Hobbes", "author" => "Bill Watterson" );
// add another record, with a different "shape"
$document = array( "title" => "XKCD", "online" => true );
// find everything in the collection
$cursor = $collection->find();
// iterate through the results
foreach ($cursor as $document) {
    echo $document["title"] . "\n";

Happy coding!

openssl CSR generieren

Ein Post, nur weil ich selber immer vergesse wie das geht.

Also, zuerst einen Private Key für den Server generieren:

openssl genrsa -out domainname.key 2048

Wer gerne noch einen Passpharse dazu haben möchte schreibt:

openssl genrsa -des3 -out domainname.key 2048

Mit dem Key kann dann der CSR erstellt werden:

openssl req -new -sha256 -key domainname.key -out domainname.csr

Danach ist das .csr File fertig. Natürlich muss der Private Key geheim bleiben, sonst kann jeder das selbe Zertifikat ausstellen und das ist – nicht gut.

© 2017 netmess

Theme by Anders NorenUp ↑