LoginSignup
1
4

More than 5 years have passed since last update.

Amazon Linux2上にwordpressをインストールした際につまづいたこと&その対処方法メモ

Last updated at Posted at 2018-01-17

久々に自分のAWS環境のEC2上にWordpressのインストールしようと思った
かつ
最近出たAmazon Linux2上にインストールした時に
若干ハマったので、その内容と解決方法をメモっておきます。
また作るとき用に残しておきます。

自動起動方法

Amazon Linuxで使えた自動起動の設定のコマンドですが、サービスの設定方法が変わっているらしく、

$ sudo chkconfig httpd on

を実行すると、使えないらしく、以下のようなメッセージを出してくれます。

Note: Forwarding request to 'systemctl enable httpd.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service

ということで、

$ sudo systemctl enable httpd.service

を実行しました。

サービスの起動停止等は以下のコマンドでした。

$ sudo systemctl [start | stop | restart] httpd.service

PHP7のインストール

何も考えずにyumでPHPをインストールしたら、5.4だったんですが、
Wordpressのプラグインで、アップロードしたファイルをS3にアップロードするWP Offload S3 Lite(Amazon S3 Cloud Front)というプラグインがあって、今回これを使いたかったのですが、PHP5.5以上じゃないと使えないことが判明。
じゃあ、どうするよと、色々調べたところ、Extras Library(amazon-linux-extras)でPHP7がインストールできるということで、

$ sudo amazon-linux-extras install php7.2

でインストール・・・と思ったら、失敗。

Package php-cli-5.4.16-43.amzn2.0.1.x86_64 already installed and latest version
Error: Package: php-json-7.2.0-3.amzn2.1.x86_64 (amzn2extra-php7.2)
Requires: php-common(x86-64) = 7.2.0-3.amzn2.1
Installed: php-common-5.4.16-43.amzn2.0.1.x86_64 (@amzn2-core)
php-common(x86-64) = 5.4.16-43.amzn2.0.1
Available: php-common-5.4.16-43.amzn2.x86_64 (amzn2-core)
php-common(x86-64) = 5.4.16-43.amzn2
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
Installation failed. Check that you have permissions to install.

あん?なんでやねんと関西弁でツッコミを入れたところで、
調べてみると、AWSのフォーラムで同じエラーが出てるというスレッドを発見

Amazon Linux 2 - Can't install PHP 7.2

google翻訳さんの力を借りて読んでみると、
とりあえず、AWSもこの問題は認識していて、アップデートするから待っててね。的なことが書いてあったので、
どーすんだとよ、再度いろいろ調べた結果、代替案としては、yumでバージョン指定してインストールするという以下の方法で対応

sudo yum install \
php-common-7.2.0-3.amzn2.0.1.x86_64 \
php-fpm-7.2.0-3.amzn2.0.1.x86_64 \
php-cli-7.2.0-3.amzn2.0.1.x86_64 \
php-mysqlnd-7.2.0-3.amzn2.0.1.x86_64 \
php-pdo-7.2.0-3.amzn2.0.1.x86_64 \
-y --disableplugin=priorities

(ただ、このコマンドどこから持ってきたか忘れているので、思い出したら追記)

公開する頃には、Extras Libraryの問題は解決してるかも。と思ったけど、フォーラム見る限りは未解決でした。

週末に続きをやるから、また、何か起きたら、さらに追記します。


2018.02.18 追記

問題修正されたようです。
コマンド実行前にyum updateが行ってください。以下スレッドの最後のコメント。
Amazon Linux 2 - Can't install PHP 7.2


参考サイト

Wordpressのインストール

AWSにWordPress3.8をインストールしてみた – その1

サービス自動起動

systemdでの自動起動設定

Extras Library(amazon-linux-extras)

Amazon Linux 2のExtras Library(amazon-linux-extras)を使ってみた
Amazon Linux2 の注意点【Zabbixの視点から】

1
4
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
1
4