environment
docker-compose.yml app container
php —7.4-apache db container
mysql: 5.5 (MySQL version matches the ClearDB of the Heroku add-on)
The error screen looks like this↓
Forbidden
You don't have permission to access this resource.
Apache/2.4.38 (Debian) Server at afternoon-atoll-83846.herokuapp.com Port 80
When I checked the error log in herokur logs, I found an error similar to the following:↓
[autoindex:error][pid21][client10.43.252.33:26285] AH01276:Cannot serve directory /var/www/html/:No matching DirectoryIndex(index.php,index.html) found, and server-generated directory index by optional
I tried to decipher the error sentence, but I couldn't find a clue to the solution.I'm sorry to bother you at such a busy time, but could you tell me something?
This is the flow until the error occurs↓
It works well on my first deployment.
If you grant permission with chmod when you deploy a new app, neither of them will stand up.
Additional
When I displayed the error again in herokurogs, I got a slightly different error log.
AH01276:Cannot serve directory /var/www/html/:No matching DirectoryIndex(index.php,index.html) found, and server-generated directory index forbidden by Options direct, refer: https://dashboard.heroku.com/
Two of the three apps don't work
One is a sample application on the official website.This works as expected.
In addition, this part of the prerequisite knowledge is lacking, and I appreciate any words you may say to change the way you ask questions!
The response is basically fast!
Do ls-al
while looking at the directory with .git
.Put the Procfile in that directory and rewrite it.
web: relative path to vendor/bin/heroku-php-apache2<src;
Heroku runs the script compile
when the source code is sent.So we prepare PHP and its library.If you don't write anything on the Procfile, the script heroku-php-apache2
will run.
So when heroku-php-apache2
runs, it prepares and starts Apache (web server) so that PHP can run.A Web server must have a starting point (root directory) for the directory to be distributed.This is configured to be a directory in the repository (directory with the .git
directory) without the Procfile
argument.Instead, pass the argument relative path to that directory as seen from the repository start point.
And the reason why the mysterious directory /var/www/html/
suddenly appears is because of Apache's settings.This Apache looks for the result of accessing index.php
or index.php
from <Repository Directory>/foo/
when accessed by directory name (for example, https://example.net/foo/).And if you don't have the results, you'll go to /var/www/html/
by default, and you'll get an error because there's nothing in it.
"If I were to go further, I couldn't find what I was looking for, so the error I should issue might be ""404 Not found"", but it's actually ""403 Forbidden""."The old Web server used to return a list of files for a directory when it was accessed.However, because of the security risks, we "banned" the web server configuration from seeing the file list.
© 2024 OneMinuteCode. All rights reserved.