Linux – WordPress and Apache 2.4 installation troubles: Cannot Serve Directory

apache-2.2apache-2.4http-status-code-403linuxWordpress

I'm having a devil of a time getting WordPress going on my webhost. When I try to access my virtualhost, I get a "403 Forbidden You don't have permission to access / on this server." error and a "Cannot serve directory…" error in my error_log (see below). Why am I getting "403 Forbidden"? I am missing something, hopefully obvious to you (not to me, naturally). Thanks for any help.

I installed a minimal install of Fedora 20 (ie, no Gnome/KDE but plenty of php packages [710] so it's not that skinny). Then I installed Apache, and followed up with the WordPress install as per http://codex.wordpress.org/Installing_WordPress#Famous_5-Minute_Install . Since then, I have been hacking around in /etc/httpd trying to find the issue.

I have version 2.4 of Apache, php 5.5.18, Fedora 20, and WordPress 4.0-1.

I have created my Virtualhost in Apache, and here is the error in my error log (all on one line):

[Sat Nov 15 20:38:16.067198 2014] [autoindex:error] [pid 6745] 
[client XX.XX.XX.XX:48419] AH01276: Cannot serve directory /usr/share/wordpress/: 
No matching DirectoryIndex (index.html) found, and server-generated directory
index forbidden by Options directive

I have been hacking and hacking the httpd.conf file and my Virtual host's file (found in /etc/httpd/conf.d/myhostname.conf) to no avail. Any ideas? I include a (shortened) copy of my httpd.conf and my virtual host's conf file. First, the virtual host:

<VirtualHost *:80>
        ServerName virtual1.myhost.com
        ServerAlias virtual1
        DocumentRoot /usr/share/wordpress
        ErrorLog logs/virtual1_error
        CustomLog logs/virtual1_access common
</VirtualHost>

<Directory />
  Require all granted
  AllowOverride None
  <IfModule mod_rewrite.so>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
  </IfModule>
</Directory>

<Directory /usr/share/wordpress>
  Require all granted
  <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
  </IfModule>
  Options FollowSymLinks
  AllowOverride None
#  <IfModule mod_authz_core.c>
#    # Apache 2.4
#    Require local
#  </IfModule>
#  <IfModule !mod_authz_core.c>
#    # Apache 2.4
#    Require all granted
#    AllowOverride None
# </IfModule>
</Directory>

<Directory /usr/share/wordpress/wp-content/plugins/akismet>
  <FilesMatch "\.(php|txt)$">
    Require all granted
    AllowOverride None
  </FilesMatch>
</Directory>

Now, the httpd.conf:

#
ServerRoot "/etc/httpd"

Listen 80
Include conf.modules.d/*.conf
User apache
Group apache
ServerAdmin root@localhost
<Directory />
    AllowOverride none
    Require all granted
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>
<Directory "/var/www/html">
    Require all granted
    Options Indexes FollowSymLinks
    AllowOverride None
</Directory>
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
#
<Files ".ht*">
    Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>
<IfModule mime_module>
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName www.myhost.com
    ServerAlias www
    ServerAdmin root@myhost.com
    DocumentRoot /var/www/html
    ErrorLog logs/error_log
    CustomLog logs/access_log common
</VirtualHost>

IncludeOptional conf.d/*.conf

Best Answer

It looks like you have forgotten DirectoryIndex.

This should be added to the <VirtualHost> serving WordPress.

DirectoryIndex index.php