How to show Directory Index in Apache 2.4 with custom Document Root

fanjavaid picture fanjavaid · Jan 25, 2014 · Viewed 59.3k times · Source

i have problem in Apache 2.4 in Ubuntu 13.10. I try to change Document Root to /home/fandi/public_html And all working fine. But i try to create folder in my public_html/ i get an error like this :

[Sat Jan 25 10:59:50.149441 2014] [autoindex:error] [pid 1093] [client 127.0.0.1:39901] AH01276: Cannot serve directory /home/fandi/public_html/report_php/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive

I must create file index.html, index.php and other index.xxx file.

In default it must show Directory Index. How to enable Directory Index?

This is my file 000-default.conf :

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/fandi/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory "/home/fandi/public_html">
        Options All
        AllowOverride All
        Require all granted
        Options Indexes FollowSymLinks
    </Directory>

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Please help, thanks before ^^

Answer

mad picture mad · Aug 1, 2014

Turns out you need to disable DirectoryIndex in Apache 2.4 to get auto Indexes.

DirectoryIndex disabled
Options Indexes

When DirectoryIndex is not disabled, auto index does not work and apache sends either a 403 Forbidden or a 404 File not found if you use fastcgi/php-fpm.

Here are the corresponding error log lines (for search purposes):

[authz_core:error] client denied by server configuration:
[proxy_fcgi:error] Got error 'Primary script unknown\n'