In the /etc/nagios3/nagios.cfg file, make sure you have similar values:

check_external_commands=1
command_check_interval=15s
command_file=/var/lib/nagios3/rw/nagios.cmd

Add www-data user to nagios group

usermod www-data -G nagios
dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw
dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios

Restart Nagios