For those of you who are exhausted by repeated Forbidden messages on Apache 2.4

Hello,
I'm Mandai, the Wild Team member of the development team.

I recently set up Apache 2.4 and was frustrated by the repeated Forbidden messages, so I've put together a list of the things I tried

 

This error content

This time the error I encountered is this:

[Mon Jun 05 09:45:45.490521 2017] [core:crit] [pid 8125] (13)Permission denied: [client 127.0.0.1:36174] AH00529: /var/www/vhosts/wordpress/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/vhosts/wordpress/' is executable, referer: http://wp.localhost/readme.html

 

In /etc/hosts, I've assigned the subdomain wp.localhost to 127.0.0.1.
As you might expect, this is a subdomain for WordPress development.

I was reusing a VM I had previously created with VirtualBox, so I thought I could skip these settings!

This time I wanted to start Eclipse on the desktop in the VM and develop, so I rebooted the computer to use two displays.
Looking back, this was not a good idea.

 

This time's solution

I searched for about an hour, and when I gave up and was about to go home thinking that all I could find was information about permissions, I saw the word SELinux, which I had completely forgotten about...
In such a case, I just honestly

sudo setenforce 0

 

This is the only option

It worked without any problems!

When I rebooted, the setenforce command I had run previously was reset.
Since this was just a temporary solution, I decided not to edit /etc/selinux/config.

The result was that I had forgotten that stance, and it was no longer a stance at all

Basically, the VM stops by "save state," so it's not shut down from the VM's perspective

 

There are other possibilities

It seems that this error is not always caused by SELinux, and I found various answers

 

If the issue is due to permissions

In this case, the document root directory (/var/www/vhosts/wordpress/ in this case) does not have viewing permissions, so you cannot access the files below it

This can be done by adding execution permissions to the document root directory

chmod +x /var/www/vhosts/wordpress/

 

So this is one such pattern

 

If the cause is user permissions

This is the first thing you might suspect
, but it's usually not the case.

In the first place, you don't create files with permissions like "770" or "750" in a development environment.
I would like to think of "755" and "644" as the basics.

 

Symbolic links are disabled

This is embarrassing but happens sometimes

Add Options FollowSymlinks

All you can do is be careful

 

summary

In this case, I would like to use the minimum configuration of httpd.conf as shown below and try to avoid setting up the environment as much as possible

<VirtualHost wp.localhost:80>ServerName wp.localhost DocumentRoot /var/www/vhosts/wordpress<Directory /var/www/vhosts/wordpress> Options FollowSymlinks Includes AllowOverride All Require all granted</Directory></VirtualHost>

 

You definitely don't want to forget this and SELinux settings

 
That's all

If you found this article useful, please click [Like]!
0
Loading...
0 votes, average: 0.00 / 10
21,543
X Facebook Hatena Bookmark pocket

The person who wrote this article

About the author

Yoichi Bandai

My main job is developing web APIs for social games, but I'm also grateful to be able to do a variety of other work, including marketing.
My portrait rights within Beyond are CC0.