# Apache22 Index of /  - but no index



## ObiektywNy (Jan 18, 2011)

OK maybe I messed up something but I'm stuck. I installed Apache22 Php5 and MySql.


```
apache-2.2.17_1
php5-5.3.5
php5-gd-5.3.2_1
php5-session-5.3.5
php5-mysql-5.3.2_1
mysql-server-5.5.5
```
I set host, I have checked patch to  root folder and I am lost to find why I can't dysplay index file from my /usr/local/www/apache22/data/folder. Instead of that I got: 


```
Index of /
Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2 PHP/5.3.5 with Suhosin-Patch Server at 192.168.1.1 Port 80
```

Below is my log tail:


```
# tail /var/log/httpd-error.log
<b>Warning</b>:  Module 'session' already loaded in <b>Unknown</b> on line <b>0</b>



<b>Warning</b>:  Module 'gd' already loaded in <b>Unknown</b> on line <b>0</b>

[Tue Jan 18 14:36:20 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20090626/mysql.so' - /usr/local/lib/libmysqlclient.so.16: version 
libmysqlclient_16 required by /usr/local/lib/php/20090626/mysql.so not defined in Unknown on line 0
PHP Warning:  Module 'session' already loaded in Unknown on line 0
PHP Warning:  Module 'gd' already loaded in Unknown on line 0
[Tue Jan 18 14:36:21 2011] [notice] Digest: generating secret for digest authentication ...
[Tue Jan 18 14:36:21 2011] [notice] Digest: done
[Tue Jan 18 14:36:22 2011] [notice] Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2 PHP/5.3.5 with Suhosin-Patch configured -- 
resuming normal operations
```


----------



## SIFE (Jan 18, 2011)

This mean two things, first may be you don't already have index.html, second check your httpd.conf and make sure you have this section

```
ee /usr/local/etc/apache22/httpd.conf
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>
/usr/local/etc/rc.d/apache22 restart
```
Also, as I see from your /var/log/httpd-error.log, you have with loading mysql extension, you may try to reinstall php5-extensions.


----------



## ObiektywNy (Jan 19, 2011)

OK I checked conf again and I decided to deinstall all php5
lang/php5
graphics/php5-gd
databases/php5-mysql

and Apache22

I removed my httpd.conf file and I installed clean apache22. I set up ServerName and the similar error 303

```
Forbidden
You don't have permission to access /server-status on this server.
Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2 Server at 192.168.1.1 Port 80[/B]
```
 
tail from log


```
[Wed Jan 19 12:50:00 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Wed Jan 19 12:50:01 2011] [notice] Digest: generating secret for digest authentication ...
[Wed Jan 19 12:50:01 2011] [notice] Digest: done
[Wed Jan 19 12:50:02 2011] [notice] Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2 configured -- resuming normal operations
```

I allow for [server-status] in httpd.conf

```
<IfModule mod_status.c>
    #
    # Allow server status reports generated by mod_status,
    # with the URL of http://servername/server-status
    # Change the ".example.com" to match your domain to enable.
    #
    ExtendedStatus On
    <Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from .example.com
    </Location>
</IfModule>
```
the same error

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

While ago I played with SSH files ssh_config and sshd_config, it is possible that I changed something there?


----------



## anomie (Jan 19, 2011)

@ObiektywNy: in the first post you were trying to access DocumentRoot, and now you're trying to access /server-status. What gives?  

There are multiple problems here. 

 Your logging doesn't reflect the errors your browser is barfing out. 
 You may be misunderstanding Apache's access control.

For logging, try setting *LogLevel info* and restart Apache. If you're still not seeing more useful info, then you're somehow looking at the wrong error log. 

For access control, remember that Apache follows "last match wins" philosophy. In your example: 

```
<Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from .example.com
    </Location>
```

The order directives says to process all deny rules first, and all allow rules second. It denies from everywhere, and then it allows from .example.com hostnames. Last match wins. (But I doubt you're on ".example.com".)


----------



## ObiektywNy (Jan 20, 2011)

Hi anomie
I added <Location /server-status> to try display  the server status.



> (But I doubt you're on ".example.com".)


 Yes thank you for point on that I miss it.

I played with those settings for a while and I realized when I have *Deny from all* no matter what I type Allow from ... my hostaname+ domain host IP I will get error 
	
	



```
You don't have permission to access /server-status on this server.
```
I did *allow from all* and I hashed *#Deny from all* and I got results on the page


```
Apache Server Status for server.mydomain.us

   Server Version: Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2

   Server Built: Jan 19 2011 10:08:45

-----------------------------------

   Current Time: Thursday, 20-Jan-2011 09:14:27 UTC

   Restart Time: Thursday, 20-Jan-2011 09:10:48 UTC

   Parent Server Generation: 8

   Server uptime: 3 minutes 39 seconds

   Total accesses: 6 - Total Traffic: 4 kB

   CPU Usage: u0 s0 cu0 cs0

   .0274 requests/sec - 18 B/second - 682 B/request

   1 requests currently being processed, 5 idle workers

 W_____..........................................................
 ................................................................
 ................................................................
 ................................................................

   Scoreboard Key:
   "_" Waiting for Connection, "S" Starting up, "R" Reading Request,
   "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
   "C" Closing connection, "L" Logging, "G" Gracefully finishing,
   "I" Idle cleanup of worker, "." Open slot with no current process

   Srv PID   Acc  M CPU  SS  Req Conn Child Slot   Client          VHost                  Request
   0-8 1434 0/3/3 W 0.00 0   0   0.0  0.00  0.00 127.0.0.1   server.example.com GET /server-status HTTP/1.1
   5-8 1442 0/3/3 _ 0.00 163 0   0.0  0.00  0.00 192.168.1.1 server.example.com GET / HTTP/1.1

-----------------------------------

    Srv  Child Server number - generation
    PID  OS process ID
    Acc  Number of accesses this connection / this child / this slot
     M   Mode of operation
    CPU  CPU usage, number of seconds
    SS   Seconds since beginning of most recent request
    Req  Milliseconds required to process most recent request
   Conn  Kilobytes transferred this connection
   Child Megabytes transferred this child
   Slot  Total megabytes transferred this slot

-----------------------------------

   SSL/TLS Session Cache Status:

-----------------------------------

    Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2 Server at server.mydomain.us Port 80
```

And I think you help me pointing on that *Deny from all* 

 I see no that I have wrong records for VHost server.mydomain.us =/= 192.168.1.1 server.example.com


----------



## ObiektywNy (Jan 20, 2011)

I changed /etc/hosts file to 


```
192.168.1.1             localhost server.mydomain.us
```

Now I have 


```
Srv  PID   Acc  M CPU  SS Req Conn Child Slot   Client          VHost                  Request
 0-11 1534 0/2/2 W 0.00 0  0   0.0  0.00  0.00 192.168.1.1 server.example.com GET /server-status HTTP/1.1
```

I still getting 
*Index of /*
Instead of index.html file

Could you help me where I should look for allconfiguration file that could affect apache?

Now won't open location that is defined in /usr/local/etc/apache22/httpd.conf (that file is almost default from fresh apache22 installation) as 
	
	



```
DocumentRoot "/usr/local/www/data"
```

Thank you


----------



## anomie (Jan 20, 2011)

ObiektywNy said:
			
		

> I played with those settings for a while and I realized when I have *Deny from all* no matter what I type Allow from ... my hostaname+ domain host IP I will get error
> 
> 
> 
> ...



That should not be so. Perhaps you can try: 

```
<Location /server-status>
        SetHandler server-status
        Order deny,allow
        Deny from all
        Allow from 192.168.1.
    </Location>
```

Because of the *Order* directive's parameter order, the *Allow* directive will always be processed last (and will supersede the *Deny*, assuming there is a pattern match). 



			
				ObiektywNy said:
			
		

> I still getting
> 
> ```
> Index of /
> ...



Well, let's see output from: 
`# ls -l /usr/local/www/data`

and

`# grep -i 'directoryindex' httpd.conf`



			
				ObiektywNy said:
			
		

> Could you help me where I should look for allconfiguration file that could affect apache?



In addition to httpd.conf, you want to look for any *Include* directives inside it, which potentially suck in more configurations.


----------



## ObiektywNy (Jan 21, 2011)

anomie said:
			
		

> Well, let's see output from:
> `# ls -l /usr/local/www/data`




```
-rw-r--r--   1 root       wheel   51 Jan 19 10:19 index.html
-rwxrwxrwx   1 root       wheel   84 Jan 17 15:01 index.php
drwxr-xr-x   2 root       wheel  512 Jan 17 15:43 php-syslog-ng
```




			
				anomie said:
			
		

> `# grep -i 'directoryindex' httpd.conf`




```
# DirectoryIndex: sets the file that Apache will serve if a directory
    DirectoryIndex index.html index.php
```


----------



## anomie (Jan 21, 2011)

Now that you've set *LogLevel info*, are you seeing anything more useful in your error log? 

Let's force an error doing the "telnet test": 

```
%telnet your.host 80
Trying 10.51.0.101...
Connected to your.host.
Escape character is '^]'.
GET /foo.gone HTTP/1.1                <-- hit enter
host: your.host                       <-- hit enter
                                      <-- hit enter
HTTP/1.1 404 Not Found
```

(Or do it the boring way, and use your web browser. )

Voila. Now check your error log. See the 404? What precise file and path is it looking for? 

If the error's not even there, something's seriously wonky. (You're looking at the wrong log, and/or you've got two http daemons running, and/or something else.)


----------



## ObiektywNy (Jan 21, 2011)

Hi anomie
I tried  display it through telnet and boring way  here are results:

```
#telnet 192.168.1.1 80
Trying 192.168.1.1...
Connected to localhost.
Escape character is '^]'.
^[
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
<h1>Method Not Implemented</h1>
<p>o / not supported.

</p>
<hr>
<address>Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2 Server at server.example.com Port 80</address>
</body></html>
Connection closed by foreign host.
```

and LOGs


```
#tail /var/log/httpd-error.log
[Thu Jan 20 09:31:11 2011] [notice] Digest: done
[Thu Jan 20 09:31:12 2011] [notice] Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2 configured -- resuming normal operations
[Thu Jan 20 09:33:08 2011] [notice] SIGHUP received.  Attempting to restart
[Thu Jan 20 09:33:08 2011] [notice] Digest: generating secret for digest authentication ...
[Thu Jan 20 09:33:08 2011] [notice] Digest: done
[Thu Jan 20 09:33:09 2011] [notice] Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2 configured -- resuming normal operations
[Thu Jan 20 09:51:27 2011] [notice] SIGHUP received.  Attempting to restart
[Thu Jan 20 09:51:28 2011] [notice] Digest: generating secret for digest authentication ...
[Thu Jan 20 09:51:28 2011] [notice] Digest: done
[Thu Jan 20 09:51:29 2011] [notice] Apache/2.2.17 (FreeBSD) mod_ssl/2.2.17 OpenSSL/0.9.8k DAV/2 configured -- resuming normal operations
```


```
#tail /var/log/httpd-access.log
127.0.0.1 - - [20/Aug/2010:12:26:45 +0000] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.16 (FreeBSD) DAV/2 PHP/5.3.2 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8k (internal dummy connection)"
127.0.0.1 - - [20/Aug/2010:12:26:45 +0000] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.16 (FreeBSD) DAV/2 PHP/5.3.2 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8k (internal dummy connection)"
127.0.0.1 - - [20/Aug/2010:12:26:45 +0000] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.16 (FreeBSD) DAV/2 PHP/5.3.2 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8k (internal dummy connection)"
127.0.0.1 - - [20/Aug/2010:12:26:45 +0000] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.16 (FreeBSD) DAV/2 PHP/5.3.2 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8k (internal dummy connection)"
127.0.0.1 - - [20/Aug/2010:12:26:45 +0000] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.2.16 (FreeBSD) DAV/2 PHP/5.3.2 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8k (internal dummy connection)"
127.0.0.1 - - [21/Sep/2010:14:19:22 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.10) Gecko/20100921 Firefox/3.6.10"
127.0.0.1 - - [04/Jan/2011:16:01:05 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.13) Gecko/20101215 Firefox/3.6.13"
192.168.1.245 - - [17/Jan/2011:14:59:35 +0000] "GET / HTTP/1.1" 200 85 "-" "Mozilla/5.0 (000000000; 0; 00000 000 00 0 000000; 00000) DDDDDDDDDDDDDDDDDD DDDDDDD DDDD DDDDDD DDDDDDDDDDDDDDDDDD DDDDDDDDDDDDD"
192.168.1.245 - - [17/Jan/2011:15:02:38 +0000] "GET /index.php HTTP/1.1" 200 84 "-" "Mozilla/5.0 (000000000; 0; 00000 000 00 0 000000; 00000) DDDDDDDDDDDDDDDDDD DDDDDDD DDDD DDDDDD DDDDDDDDDDDDDDDDDD DDDDDDDDDDDDD"
192.168.1.245 - - [17/Jan/2011:15:03:40 +0000] "GET / HTTP/1.1" 200 84 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"
```


----------



## ObiektywNy (Jan 21, 2011)

Got it
I look wrong log
While ago I installed php-syslog-ng and according to your suggestion I look in to logs one by one and i found that save date it stops in httpd-access.log while ago so I did 

```
#tail /var/log/php-syslog-ng-error.log
```

and *TaDaaa*

```
[Fri Jan 21 15:39:40 2011] [error] [client 192.168.1.1] File does not exist: /usr/local/www/data/php-syslog-ng/index.html
```
 now I have to find where is that setting that overwrite DirectoryIndex in httpd.conf with 
*/usr/local/www/data/php-syslog-ng/*

Thank you so much for you support and suggestion *anomie* I appreciate your help.


----------



## anomie (Jan 22, 2011)

Now you're talking. What PID does the following command tell you? 

`# fstat /var/log/php-syslog-ng-error.log`

Take that PID, and then use it in this command: 

`# ps auxww -p PID_HERE`

That might give you enough information to figure out which config file the http daemon is reading. _That_ is where you need to make your *DocumentRoot* change (and possibly others).


----------



## ObiektywNy (Jan 22, 2011)

anomie said:
			
		

> `# fstat /var/log/php-syslog-ng-error.log`
> `# ps auxww -p PID_HERE`




```
# fstat /var/log/php-syslog-ng-error.log
USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W NAME
```
I found file in /usr/local/etc/apache22/Includes/syslogweb.conf

And there my patch  yep it happens - I started syslog installation and I pass it of some other project and after few months I forgot what I did - my fault

I disabled now it from rc.conf

```
mysql_enable="YES"
#apache22_http_accept_enable="YES"
apache22_enable="YES"
ftpd_enable="YES"

syslog_enable="YES"
#syslogd_enable="NO"
#syslog_ng_enable="YES"
#syslogd_program="/usr/local/sbin/syslog-ng"
#syslogd_flags=""
```
so syslog will not run now and I have to start over again from scratch.

Any ideas what is the best tutorial for syslog server, I plan to capture logs from some of my devices as switches and access points, save it in to mysql and make PHP interface for it - probably it is topic for next post but if someone know good website I appreciate a link


----------

