---
title: "Permission denied: exec of '/usr/local/nagios/sbin/status.cgi' failed"
author: "libin123"
date: "2012-07-16T18:26:49Z"
tags: []
categories: ["开源软件"]
slug: "permission-denied-exec-of-usr-local-nagios-sbin-status-cgi-failed"
draft: false
lastmod: "2012-07-16T18:26:49Z"
id: 1595534
url: "https://dbua.iteye.com/blog/1595534"
---

nagios登陆正常，但是访问所有的服务出错，检查nagios的配置文件，是正确的

在 /var/log/httpd error\_log中发现出现以下错误:

 

\[Mon Jul 16 17:29:23 2012] \[error] \[client 192.168.1.212] (13)Permission denied: exec of '/usr/local/nagios/sbin/status.cgi' failed,  
referer: [http://192.168.1.217/nagios/side.php](http://192.168.1.217/nagios/side.php)  
\[Mon Jul 16 17:29:23 2012] \[error] \[client 192.168.1.212] Premature end of script headers: status.cgi, referer: [http://192.168.1.217](http://192.168.1.217)  
/nagios/side.php  
\[Mon Jul 16 17:29:28 2012] \[error] \[client 192.168.1.212] PHP Warning: date(): It is not safe to rely on the system's timezone sett  
ings. You are \*required* to use the date.timezone setting or the date\_default\_timezone\_set() function. In case you used any of those  
methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' fo  
r 'CST/8.0/no DST' instead in /usr/local/nagios/share/main.php on line 123, referer: [http://192.168.1.217/nagios/side.php](http://192.168.1.217/nagios/side.php)  
\[Mon Jul 16 17:29:37 2012] \[error] \[client 192.168.1.212] PHP Warning: MagpieRSS: Failed to fetch [http://www.nagios.org/backend/fee](http://www.nagios.org/backend/fee)  
ds/frontpage/ and cache is off in /usr/local/nagios/share/includes/rss/rss\_fetch.inc on line 238, referer: [http://192.168.1.217/nagi](http://192.168.1.217/nagi)  
os/main.php

 

 

解决方法

 

如果是SELinux处于强制安全模式时需要做

```
getenforce
```

 

令SELinux处于容许模式

```
setenforce 0
```

 

如果要永久性更变它，需要更改**/etc/selinux/config**里的设置并重启系统。

 

不关闭SELinux或是永久性变更它的方法是让CGI模块在SELinux下指定强制目标模式：

```
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
```