ansible初心者なので、改善点とかありましたら教えてください
先にApache2とMySQLをインストールしている前提です。
Apache2のインストールはこちらをご覧ください
MySQLのインストールはこちらをご覧ください
install-php-playbook.yml
- hosts: [web-server]
vars:
src_dir: "/usr/local/src"
php_src_dir: "$src_dir/php"
php_version: "5.5.4"
php_src_url: "http://jp1.php.net/distributions/php-$php_version.tar.gz"
tasks:
- name: "remove installed package"
yum: name=php state=absent
- name: "install depended package"
yum: name=$item
with_items:
- perl
- gd-devel
- libjpeg-devel
- libpng-devel
- libxml2
- libxml2-devel
- openssl
- openssl-devel
- name: "make src dir"
file: dest=$php_src_dir state=directory
- name: "download php src"
get_url: url=$php_src_url dest=$php_src_dir
- name: "extract src file"
command: tar zxvf php-$php_version.tar.gz chdir=$php_src_dir
- name: "create mysql synbolic link"
file: src=/usr/lib64/mysql dest=/usr/lib/mysql state=link
- name: "configure"
command: chdir=$php_src_dir/php-$php_version env ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --enable-mbstring --enable-mbregex --disable-cgi --enable-cli --with-zlib --with-gd --with-jpeg-dir=/usr/local/src/php/php-$php_version/ext/gd/libgd --with-png-dir=/usr/local/src/php/php-$php_version/ext/gd/libgd --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
- name: "make"
command: make chdir=$php_src_dir/php-$php_version
- name: "install"
command: make install chdir=$php_src_dir/php-$php_version
- name: "copy initial php.ini"
copy: src=$php_src_dir/php-$php_version/php.ini-production dest=/usr/local/lib/php.ini
- name: "set mime type to httpd conf"
command: echo 'application/x-httpd-php php html' >> /usr/local/apache2/conf/mime.types