Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ^^

like image 434
fanjavaid Avatar asked Jan 25 '14 04:01

fanjavaid


People also ask

Which is the root directory for Apache?

By default, the Apache web root or Document root folder location is at /var/www/html.

What is document root and directory in Apache?

Introduction. On Ubuntu, the Apache web server serves documents stored in the var/www/html directory by default. This directory is referred to as the document root.


2 Answers

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'
like image 181
mad Avatar answered Sep 24 '22 22:09

mad


Options All <--turn on all options
Options Indexes FollowSymLinks   <--- replace previously set options with these two

The second line is redundant, because you've already turned on all the options with the first line, and since the two options aren't prefixed with +, they actually REPLACE the entire options list enabled set with All with just those two individual options.

like image 27
Marc B Avatar answered Sep 20 '22 22:09

Marc B