2

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 [email protected] DocumentRoot /var/www/html ErrorLog logs/error_log CustomLog logs/access_log common </VirtualHost> IncludeOptional conf.d/*.conf 

2 Answers 2

3

It looks like you have forgotten DirectoryIndex.

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

DirectoryIndex index.php 
1
  • Thanks, Michael. This did it. I had been having problems getting apache to recognize my virtual hostname, so I had removed all files from /etc/httpd/conf.d/ except the one virtual host I was interested in. This had the side effect of removing the DirectoryIndex directive because as it turns out, it was there all along in the php.conf file. Your fix worked; then I looked for instances of DirectoryIndex in /etc/httpd/* and found it in the aforementioned php.conf. I have returned the file to its proper place and all is well. Commented Nov 17, 2014 at 3:02
0

In the log you can find an error

[Sun Dec 03 17:38:17.649269 2017] [autoindex:error] [pid 4806] [client ::1:57323] AH01276: Cannot serve directory /etc/httpd/conf/htdocs/: No matching DirectoryIndex () found, and server-generated directory index forbidden by Options directive

to fix it:-

then you must remove the line in /etc/httpd/conf.d/welcome.conf

below existing configuration:- <LocationMatch "^/+$"> Options -Indexes ErrorDocument 403 /.noindex.html </LocationMatch>

solved with the below configuration,:- commented out a line.

<LocationMatch "^/+$"> #Options -Indexes ErrorDocument 403 /.noindex.html </LocationMatch>

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.