LoginSignup
4
2

More than 3 years have passed since last update.

【AWS】Wordpress「返答が正しいJSONレスポンスではありません」の対処法

Last updated at Posted at 2020-07-09

現象

Amazon LinuxインスタンスでWordpressをたてた。その際パーマリンクを基本→投稿名に変更して記事を投稿しようとするも、「返答が正しいJSONレスポンスではありません」とエラーが出て投稿できない&トップページ以外が表示できなくなってしまった。
スクリーンショット 2020-07-09 10.48.58.png

wordpress返答が正しいJSONレスポンスではありません
上記記事でapache設定が原因とわかった。

sudo vi /etc/apache2/apache2.conf

記事の通り上記コマンドで設定ファイルに入ろうとするも、Amazon Linuxではそのようなファイルがなかった。
Amazon LinuxはRedHat系ベースに対し、上のものはDabianの設定ファイルになっているためだ。

参考
http://www.linux.net-japan.info/install08.html
https://www.acrovision.jp/service/aws/?p=653

対処法

AWSドキュメントに方法が書いてあった。
WordPress がパーマリンクを使用できるようにするには

1.該当のインスタンスに接続した上で、下記コマンドでファイルに入る。

sudo vim /etc/httpd/conf/httpd.conf

2.<Directory "/var/www/html">で始まるセクションを見つける。(※複数の AllowOverride行があるため、間違えないように。必ず <Directory "/var/www/html">セクションの行を探す。vimで/htmlと検索すると、すぐ見つかる。)

<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

3.上のセクションをAllowOverride None行をAllowOverride Allに変更。(None→All)

4.ファイルを:wqで保存する。

5.上記設定を反映させるため、sudo systemctl restart httpd.serviceで再起動させる。sudo systemctl status httpd.serviceで念のためアクティブになっているか確認。

上記設定をするとパーマリンクを基本以外にしても、記事の投稿ができたりトップページ以外も参照できるようになる。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2