Help us understand the problem. What is going on with this article?

Forbidden You don't have permission to access this resource出た時の解決策

結論

公開ディレクトリ先のvar/www/htmlのhtmlディレクトリの所有者をapacheに変更した

まずは現在の所有者を確認してみる。

[root@ip-172-31-28-29 html]# cd ..

[root@ip-172-31-28-29 www]# pwd
/var/www

[root@ip-172-31-28-29 www]# ls -l
total 0
drwxr-xr-x 2 root     root    6 Oct 22 22:59 cgi-bin
drwxrw-rwx 3 ec2-user apache 51 Feb 15 09:43 html

所有者がec2-userになっていたので今回のエラーが出ていました。

エラー.png

所有者をapacheに変更する

chown -R apache:apache 実行させるフォルダ

[root@ip-172-31-28-29 www]# chown -R apache:apache html

[root@ip-172-31-28-29 www]# ls -l
total 0
drwxr-xr-x 2 root   root    6 Oct 22 22:59 cgi-bin
drwxrw-rwx 3 apache apache 51 Feb 15 09:43 html

[root@ip-172-31-28-29 www]# systemctl restart httpd

これで所有者がapacheに変更しました。
念のためsystemctl restart httpdを行い再起動させましょう。

無事、表示することができました。
apache所有者.png

htmlディレクトリ先のファイルの所有者は?

関係無かったですが、htmlディレクトリ先のファイルの所有者も公開しておきます。

[root@ip-172-31-28-29 html]# pwd
/var/www/html

[root@ip-172-31-28-29 html]# ls -l
total 8
drwxrwxrwx 2 ec2-user ec2-user 19 Feb 15 09:43 test
-rwxrwxrwx 1 ec2-user root     11 Feb 12 23:17 test.html
-rw-r--r-- 1 ec2-user root     22 Feb 14 14:45 test.php
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした