LoginSignup
10
11

More than 5 years have passed since last update.

CentOS7でansibleを使ってnginx+wordpressを構築

Posted at

ansible使ってnginx+wordpress環境を構築したので、メモ。

ansibleのplaybookは以下のものをそのまままるっと使わせてもらいました
ansible/ansible-examples
⇛nginx+wordpress

このまま、hostの設定とパスワードとかの設定だけ書き換えればいけるかなと
思ったらMysqlとnginxのインストールでこけた

Mysqlのインストール

CentOS 7 の標準リポジトリからはMysqlが消えたみたいで、
そんなパッケージねーよって言われた

TASK: [mysql | Install Mysql package] ***************************************** 
failed: [MY-WORDPRESS] => (item=mysql-server,MySQL-python,libselinux-python,libsemanage-python) => {"changed": false, "failed": true, "item": "mysql-server,MySQL-python,libselinux-python,libsemanage-python", "rc": 0, "results": []}
msg: No Package matching 'mysql-server' found available, installed or updated

なのでmysqlインストールする前にmysqlの公式リポジトリを追加してあげる

roles/mysql/task/main.yml
- name: Install Mysql repository
  yum: name=http://dev.mysql.com/get/mysql-community-release-el7-7.noarch.rpm state=present

上記を一番最初に追加

mysqlのyum リポジトリは以下のURLから
http://dev.mysql.com/downloads/repo/yum/

Nginxのインストール

nginxはEPEL7からインストールできないのか
以下のエラーで怒られ

msg: Error: Package: nginx-1.0.15-12.el6.x86_64 (epel)
           Requires: perl(:MODULE_COMPAT_5.10.1)
Error: Package: nginx-1.0.15-12.el6.x86_64 (epel)
           Requires: libpcre.so.0()(64bit)

こちらも同じく公式のリポジトリを追加してあげればいける

- name: Install nginx repository
  yum: name=http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm state=present

リポジトリのURLは以下でいいのかな??
http://nginx.org/en/linux_packages.html#stable

結果

PLAY RECAP ******************************************************************** 
MY-WORDPRESS               : ok=28   changed=18   unreachable=0    failed=0  

やったー

ansible公式のサンプル集は綺麗に書かれているのでわかりやすくて
いい感じです

10
11
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
10
11