Nagios could not stat nagios.cmd

After a new Nagios installation on a Debian server I usually get one of the following errors....
I Know it has something to do with the default permission structure of my installation, but this is how I fixed it:


Error: Could not stat() command file '/usr/local/nagios/var/rw/nagios.cmd'!


Oct 19 20:52:25 nagios nagios: qh: Failed to init socket '/usr/local/nagios/var/rw/nagios.qh'. bind() failed: No such file or directory

To fix this, I changed the permissions to:

chmod 666 /usr/local/nagios/var/rw/nagios.cmd
chown nagios.nagcmd /usr/local/nagios/var/rw
chmod u+rwx /usr/local/nagios/var/rw
chmod g+rwx /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw 

Now restart Nagios :-)