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

Hello.
I'm Mandai, the Wild team member in charge of development.
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, it's a development subdomain for WordPress.
I was reusing a VM I had previously created with VirtualBox, so I thought I could skip these settings!
This time, I decided to develop using Eclipse on the desktop within the VM, so I restarted my computer to use two displays.
Looking back, that was a mistake.
This time's solution
After researching for about an hour, and realizing that all I could find was information about permissions, I was about to give up and go home when I suddenly remembered SELinux...
In times like these, it's best to just...
sudo setenforce 0
This is the only option
It worked without any problems!
So, when the system restarted, the setenforce command that was executed last time was reset, right?
Since it was just a temporary fix, 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 that comes to mind.
But usually, it's not that.
Generally speaking, you wouldn't create files with permissions like "770" or "750" in a development environment.
It's best to aim for permissions like "755" or "644" as the standard.
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
0
