# nagios web start error



## mfaridi (Apr 28, 2010)

I install nagios 2 from ports and after install I do this 
I go to this directory 

```
cd /usr/local/etc/nagios
```
and run these commands

```
cd /usr/local/etc/nagios
cp cgi.cfg-sample cgi.cfg
cp nagios.cfg-sample nagios.cfg
cp resource.cfg-sample resource.cfg
cd objects
cp commands.cfg-sample commands.cfg
cp printer.cfg-sample printer.cfg
cp localhost.cfg-sample localhost.cfg
cp switch.cfg-sample switch.cfg
cp tempelates.cfg-sample tempelates.cfg
cp timeperiods.cfg-sample timeperiods.cfg
cp contacts.cfg-sample contacts.cfg
```
and after that I make this file

```
nagios.conf
```
in this Directory

```
/usr/local/etc/apache22/Includes
```
and I put these line in that file

```
<Directory /usr/local/www/nagios>
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
        AuthName "Nagios Access"
        Authtype Basic
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
        Require valid-user
</Directory>

<Directory /usr/local/www/nagios/cgi-bin>
        Options ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
        AuthName "Nagios Access"
        Authtype Basic
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
        Require valid-user
</Directory>

ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
Alias /nagios/ /usr/local/www/nagios/
```
and after that I restart apache 
but when I type in firefox 

```
http://192.168.0.58/nagios/
```
I see this error

```
The requested URL /nagios/ was not found on this server
```
and Is see error about 404
but when I see this command

```
tail -f /var/log/http-error.log
```
I see this 

```
Wed Apr 28 13:07:15 2010] [error] [client 192.168.0.58] File does not exist: /usr/local/www/apache22/data/nagios
```
and I can not access to nagios web page 
when I run this command 

```
/usr/local/etc/rc.d/nagios start
```
I do not see about starting nagios

Where I make mistake ?


----------



## SirDice (Apr 28, 2010)

mfaridi said:
			
		

> ```
> <Directory [b]/usr/local/www/nagios[/b]>
> ```
> 
> ...



Note the different path.


----------



## mfaridi (Apr 28, 2010)

SirDice said:
			
		

> Note the different path.



So you saif I must move nagios folder to ?

```
/usr/local/www/apache22/data
```
but it install by default in way


----------



## SirDice (Apr 28, 2010)

No, you should fix the error in your config. There's a reason why apache thinks it's in /usr/local/www/apache22/.


----------



## mfaridi (Apr 28, 2010)

SirDice said:
			
		

> No, you should fix the error in your config. There's a reason why apache thinks it's in /usr/local/www/apache22/.



but I think apache conf dose not error 
because I have joomla , Gallery , squrrielmail , and all of them work good


----------



## DutchDaemon (Apr 28, 2010)

Your httpd.conf for 192.168.0.58 has /usr/local/www/apache22/data as the DocumentRoot, so unless you create a new virtual host for Nagios with its own DocumentRoot, nothing in the included nagios.conf will override the DocumentRoot you have now. 

This is why http://192.168.0.58/nagios/ expands to http://192.168.0.58/$DocumentRoot/nagios/ -> /usr/local/www/apache22/data/nagios

Try [cmd=]ln -s /usr/local/www/nagios /usr/local/www/apache22/data/[/cmd]

or create a separate VirtualHost for Nagios (if you have an internal domain, create a host 'nagios' under it with /usr/local/www/nagios as its DocumentRoot).

The first solution (the symlink) should work right away, the second solution (creating a separate VirtualHost for nagios) takes some work (and a domain, of course).


----------



## mfaridi (Apr 28, 2010)

DutchDaemon said:
			
		

> Your httpd.conf for 192.168.0.58 has /usr/local/www/apache22/data as the DocumentRoot, so unless you create a new virtual host for Nagios with its own DocumentRoot, nothing in the included nagios.conf will override the DocumentRoot you have now.
> 
> This is why http://192.168.0.58/nagios/ expands to http://192.168.0.58/$DocumentRoot/nagios/ -> /usr/local/www/apache22/data/nagios
> 
> ...



Thanks 
But I see this error when I type in FireFox

```
You don't have permission to access /nagios/ on this server
```


----------



## DutchDaemon (Apr 28, 2010)

Do you have FollowSymLinks as an (added) option in httpd.conf's <Directory "/usr/local/www/apache22/data"> container?


----------



## mfaridi (Apr 28, 2010)

DutchDaemon said:
			
		

> Do you have FollowSymLinks as an (added) option in httpd.conf's <Directory "/usr/local/www/apache22/data"> container?



Yes I have this is part of http.conf

```
Directory "/usr/local/www/apache22/data">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks
```

but when I run this command 

```
tail -f /var/log/http-error.log
```
I see this

```
[Wed Apr 28 18:30:32 2010] [error] [client 192.168.0.58] Symbolic link not allowed or link target not accessible: /usr/local/www/apache22/da
```


----------



## DutchDaemon (Apr 28, 2010)

What happens when you do this on the command-line
[cmd=]cd /usr/local/www/apache22/data/nagios && ls -ld[/cmd]
?


----------



## mfaridi (Apr 28, 2010)

DutchDaemon said:
			
		

> What happens when you do this on the command-line
> [cmd=]cd /usr/local/www/apache22/data/nagios && ls -ld[/cmd]
> ?



I see this

```
drwxr-xr-x  10 root  wheel  512 Apr 28 12:28
```


----------



## DutchDaemon (Apr 28, 2010)

That should be enough (world-executable).

Do you also have this in the Directory container?


```
# Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
```

I don't think I needed to set more to get symlinks working with Apache.


----------



## mfaridi (Apr 28, 2010)

DutchDaemon said:
			
		

> That should be enough (world-executable).
> 
> Do you also have this in the Directory container?
> 
> ...



this is my nagis.conf in 

```
/usr/local/etc/apache22/Includes
```


```
<Directory /usr/local/www/nagios>
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
              
        AuthName "Nagios Access"
        Authtype Basic
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
        Require valid-user
</Directory>

<Directory /usr/local/www/nagios/cgi-bin>
        Options ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
        
        AuthName "Nagios Access"
        Authtype Basic
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
        Require valid-user
</Directory>

ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
Alias /nagios/ /usr/local/www/nagios/
```


----------



## DutchDaemon (Apr 28, 2010)

I meant the <Directory "/usr/local/www/apache22/data"> container.


----------



## DutchDaemon (Apr 28, 2010)

You can also try an alternative nagios.conf to keep the symlink intact:


```
<Directory /usr/local/www/apache22/data/nagios>
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
              
        AuthName "Nagios Access"
        Authtype Basic
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
        Require valid-user
</Directory>

<Directory /usr/local/www/apache22/data/nagios/cgi-bin>
        Options ExecCGI
        AllowOverride None
        Order allow,deny
        Allow from all
        
        AuthName "Nagios Access"
        Authtype Basic
        AuthUserFile /usr/local/etc/nagios/htpasswd.users
        Require valid-user
</Directory>

ScriptAlias /nagios/cgi-bin/ /usr/local/www/apache22/data/www/nagios/cgi-bin/
Alias /nagios/ /usr/local/www/apache22/data/nagios/
```


----------



## mfaridi (Apr 28, 2010)

DutchDaemon said:
			
		

> I meant the <Directory "/usr/local/www/apache22/data"> container.



Yes I have this 

```
#
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
</Directory>
```


----------



## mfaridi (Apr 28, 2010)

DutchDaemon said:
			
		

> You can also try an alternative nagios.conf to keep the symlink intact:
> 
> 
> ```
> ...



I use this new conf you say , but I see that error again about forbidden


----------



## DutchDaemon (Apr 28, 2010)

I'm assuming you restarted Apache after making changes?


----------



## mfaridi (Apr 28, 2010)

DutchDaemon said:
			
		

> I'm assuming you restarted Apache after making changes?



I reset apache , but nothing happen


----------



## DutchDaemon (Apr 28, 2010)

Ok, just to rule out any problem with symlinks in general, can you try this?

[cmd=]cd /usr/local/www/apache22/data[/cmd]
[cmd=]ln -s /tmp test[/cmd]

Then go to http://192.168.0.58/test -- you should see the contents of your /tmp directory now.


----------



## FBSDin20Steps (Apr 28, 2010)

> You don't have permission to access /nagios/ on this server



Did you create a webuser for nagios?


----------



## mfaridi (Apr 29, 2010)

DutchDaemon said:
			
		

> Ok, just to rule out any problem with symlinks in general, can you try this?
> 
> [cmd=]cd /usr/local/www/apache22/data[/cmd]
> [cmd=]ln -s /tmp test[/cmd]
> ...



I go to apache22/data and run this command 
[cmd=]ln -s /tmp test[/cmd]
and I open firefox and run this 
http://192.168.0.58/test
but I see error about permission and I see error about 403 forbidden

```
You don't have permission to access /test on this server
```


----------



## DutchDaemon (Apr 29, 2010)

Can you put an empty index.html file in /tmp?

[cmd=]touch /tmp/index.html[/cmd]

And try again?


----------



## mfaridi (Apr 29, 2010)

DutchDaemon said:
			
		

> Can you put an empty index.html file in /tmp?
> 
> [cmd=]touch /tmp/index.html[/cmd]
> 
> And try again?



I run this command 
[cmd=]touch /tmp/index.html[/cmd]
and type in FireFox

```
http://192.168.0.90/index.html
```
and I see this 

```
it works
```
I see this message when I type

```
http://192.168.0.90
```


----------



## DutchDaemon (Apr 29, 2010)

You'll have to try http://192.168.0.xx/*test* again, because "test" point to /tmp.


----------



## mfaridi (Apr 29, 2010)

DutchDaemon said:
			
		

> You'll have to try http://192.168.0.xx/*test* again, because "test" point to /tmp.



I see error about 403 forbidden

```
You don't have permission to access /test on this server.
```


----------



## DutchDaemon (Apr 29, 2010)

Still the symlink error in the error log?


----------



## mfaridi (Apr 29, 2010)

DutchDaemon said:
			
		

> Still the symlink error in the error log?



I see this

```
29 17:35:04 2010] [error] [client 192.168.0.90] 
Symbolic link not allowed or link target not accessible: /usr/local/www/apache22/data/test
```


----------



## DutchDaemon (Apr 29, 2010)

Well, I don't think there are any more options to allow symlinks (that I know of right now), so you can try taking this approach from the other side:


```
cd /usr/local/www/apache22/data/
rm nagios
mv /usr/local/www/nagios . ( <--- yes, that's a dot)
ln -s /usr/local/www/apache22/data/nagios /usr/local/www/
```

And try http://192.168.0.xx/nagios/ again. Make sure to use that new nagios.conf you made.


----------



## mfaridi (Apr 29, 2010)

DutchDaemon said:
			
		

> Well, I don't think there are any more options to allow symlinks (that I know of right now), so you can try taking this approach from the other side:
> 
> 
> ```
> ...



Thanks
I do that and right now I can see nagios pages with apache 
but I do not understand this 

```
Make sure to use that new nagios.conf you made
```
and another problem is this when I go to nagios page and for example services I see message like this 
new page is open and I see this

```
You have chosen to  open status.cgi  which is binary File from http://192.168.0.85 Would you like to save this file
```


----------



## DutchDaemon (Apr 29, 2010)

I mean the nagios.conf from post #15, which contains the correct pathnames (<Directory /usr/local/www/apache22/data/nagios>).

Do you have the cgi modules loaded?

[cmd=]httpd -M | grep -i cgi[/cmd]

```
cgi_module (shared)
 scgi_module (shared)
```

They should be in httpd.conf as:


```
LoadModule cgi_module libexec/apache22/mod_cgi.so
LoadModule scgi_module          libexec/apache22/mod_scgi.so
```

This only works if you compiled Apache with:


```
[X] CGI                   Enable mod_cgi
```


----------



## mfaridi (Apr 29, 2010)

DutchDaemon said:
			
		

> I mean the nagios.conf from post #15, which contains the correct pathnames (<Directory /usr/local/www/apache22/data/nagios>).
> 
> Do you have the cgi modules loaded?
> 
> ...



I have this 

```
LoadModule cgi_module libexec/apache22/mod_cgi.so
```
and when I run this command

```
[cmd=]httpd -M | grep -i cgi[/cmd]
```
I see this

```
Syntax OK
 cgi_module (shared)
```
I use your nagios.conf from post number 15


----------



## DutchDaemon (Apr 29, 2010)

Ok, a few things to check:

1. Do you have this line in httpd.conf?


```
Include etc/apache22/Includes/*.conf
```

2. Is your nagios.conf in /usr/local/etc/apache22/Includes/nagios.conf ?

3. Do all real pathnames (to directories and files) in your nagios.conf exist? Just run 'ls -l' to each pathname to see if they actually exist (not /nagios/ and /nagios/cgi-bin/, because those are aliased).


----------



## mfaridi (Apr 29, 2010)

Yes I have this 

```
Include etc/apache22/Includes/*.conf
```
Yes my nagios.conf is in this path 

```
/usr/local/etc/apache22/Includes/nagios.conf
```


----------



## DutchDaemon (Apr 29, 2010)

Check the pathnames in nagios.conf, one by one.


----------



## mfaridi (Apr 29, 2010)

I run this command

```
cd /usr/local/www/nagios/cgi-bin/
```
and I see this

```
usr/local/www/nagios/cgi-bin # ls
avail.cgi		extinfo.cgi		notifications.cgi	status.cgi		summary.cgi
cmd.cgi			histogram.cgi		outages.cgi		statusmap.cgi		tac.cgi
config.cgi		history.cgi		showlog.cgi		statuswml.cgi		trends.cgi
```


----------



## DutchDaemon (Apr 29, 2010)

Ah, I see the error in that nagios.conf:


```
ScriptAlias /nagios/cgi-bin/ /usr/local/www/apache22/data/www/nagios/cgi-bin/
```

must be


```
ScriptAlias /nagios/cgi-bin/ /usr/local/www/apache22/data/nagios/cgi-bin/
```

Without a correct and valid ScriptAlias Apache will not run cgi scripts.


----------



## mfaridi (Apr 29, 2010)

DutchDaemon said:
			
		

> Ah, I see the error in that nagios.conf:
> 
> 
> ```
> ...



I check that and put new path for cgi in nagios.conf

but I see that error again and Firefox and opera want download cgi file
I think I have big error in http.conf


----------



## DutchDaemon (Apr 29, 2010)

Restarted Apache, I hope?


----------



## mfaridi (May 1, 2010)

DutchDaemon said:
			
		

> Restarted Apache, I hope?



I restart apache , but still I have that error


----------



## mfaridi (May 1, 2010)

I make big mistake , my httpd.conf has many error , so I delete it and after delete I copy original one ih apache directory and modify it for use php and php5 and do not touch nothing , after that I restart it and I do not see error , so I type this http://192.168.0.xx/nagios/ and I see error about 403 forbidden and I can not access to nagios web page , so I do this 

```
cd /usr/local/www/apache22/data/
rm nagios
mv /usr/local/www/nagios . ( <--- yes, that's a dot)
ln -s /usr/local/www/apache22/data/nagios /usr/local/www/
```
but after restart apache , I see again error about forbidden to nagios
but other thing like
http://192.168.0.xx/joomla
http://192.168.0.xx/gallery2
http://192.168.0.xx/squirrelmail
http://192.168.0.xx/roundcube

works good
after I make new http.conf 
I do not see error in 
http-error.log
about permission
and I see not this error

```
Symbolic link not allowed or link target not accessible: /usr/local/www/apache22/data/nagios
```


----------



## mfaridi (May 3, 2010)

After long time search and deinstall nagios I see this end of installation 

```
nable Nagios in /etc/rc.conf with the following line:

   nagios_enable="YES"

 Configuration templates are available in /usr/local/etc/nagios as
 *.cfg-sample files.  Copy them to *.cfg files where required and
 edit to suit your needs.  Documentation is available in HTML form
 in /usr/local/www/nagios/docs.

 If you don't already have a web server running, you will need to
 install and configure one to finish off your Nagios installation.
 When used with Apache, the following should be sufficient to publish
 the web component of Nagios (modify the allow list to suit):

   <Directory /usr/local/www/nagios>
     Order deny,allow
     Deny from all
     Allow from 127.0.0.1
     php_flag engine on
     php_admin_value open_basedir /usr/local/www/nagios/:/var/spool/nagios/
   </Directory>

   <Directory /usr/local/www/nagios/cgi-bin>
     Options ExecCGI
   </Directory>

   ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
   Alias /nagios/ /usr/local/www/nagios/
```
I put this in nagios.conf in 

```
/usr/local/etc/apache22/Includes
```
I see error about 403 forbidden and I see I do not have permission 
so I delete nagios.conf from

```
/usr/local/etc/apache22/Includes
```
and put this file 

```
/usr/local/etc/apache22/httpd.conf
```
 and restart apache and every thing work good and I can use nagios 
but I like put it 

```
/usr/local/etc/apache22/Includes
```
I do not know why when I put in this directory

```
/usr/local/etc/apache22/Includes
```
it dose not work and I see error about permission


----------



## joehillen (May 3, 2010)

I have been having this issue too. I was able to fix the permission problem by adding the line.


```
DirectoryIndex index.php
```

but now I am running into an issue with PHP. When I open, http://server/nagios/ in firefox. It just shows the index.php files as text and it is not actually running the php code.

I added the lines:

```
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
```

but it has still not helped.


----------



## mfaridi (May 3, 2010)

joehillen said:
			
		

> I have been having this issue too. I was able to fix the permission problem by adding the line.
> 
> 
> ```
> ...



I have all of them in my http.conf
I think problem is another thing


----------



## joehillen (May 3, 2010)

Did you try adding it inside <Directory /usr/local/www/nagios/>?

Here is what mine looks like:

```
<Directory /usr/local/www/nagios/>
        DirectoryIndex index.php
        Order deny,allow
        Allow from all
        php_flag engine on
        php_admin_value open_basedir /usr/local/www/nagios/:/var/spool/nagios/
</Directory>
```

Also, I figured out the php not running issue. I have to go to http://server/nagios/index.php or fix the Alias:

```
Alias /nagios "/usr/local/www/nagios/"
ScriptAlias /nagios/cgi-bin /usr/local/www/nagios/cgi-bin/
```
Notice the "/" at the end the the path in the Directory tag above.


----------



## mfaridi (May 6, 2010)

after update all ports and reinstall apache22 , php5 , php5-extension and reinstall all service run by apache like nagios , phpbb , and ,,,
everything are ok right now ,
I do not understand what was problem


----------

