砂拉豆 发表于 2018-1-3 12:29:33

使用Ansible安装部署nginx+php+mysql之安装php(2)

  二、使用Ansible安装php
  1、php.yaml文件内容
  

- hosts: clong  

remote_user: root  

gather_facts: no  

tasks:  

# 安装libselinux-python  

- name: isntall libselinux-python  

yum: name=libselinux-python state=present  

# 安装epel源  

- name: install epel-release repo  

yum: name=epel-release state=present  

# 安装rpm包  

- name: install remote php rpm  

yum: name=http://rpms.famillecollet.com/enterprise/remi-release-7.rpm state=present  

# 安装php5.6  

- name: install php  

yum: name={{ item }} state=present enablerepo=remi enablerepo=remi-php56  

with_items:  

- php  

- php-opcache  

- php-devel  

- php-mbstring  

- php-mcrypt  

- php-mysqlnd  

- php-phpunit-PHPUnit  

- php-pecl-xdebug  

- php-pecl-xhprof  

- php-mysql  

- php-pecl-apcu  

- php-pdo  

- php-pear  

- php-fpm  

- php-cli  

- php-xml  

- php-bcmath  

- php-process  

- php-gd  

- php-common  

- php-json  

- php-pdo_dblib  

- php-pgsql  

- php-recode  

- php-snmp  

- php-soap  

- php-pecl-zip  

- libjpeg*  

- php-imap  

- php-ldap  

- php-odbc  

- php-xmlrpc  

- php-mbstring  

- php-bcmath  

- php-mhash  

- libmcrypt  

- libmcrypt-devel  

# 开启php-fpm  

- name: start php-fpm  

service: name=php-fpm state=started enabled=yes  

# 复制index.php文件到网站根目录  

- name: copy index.php  

copy: src=index.php dest=/usr/share/nginx/html/index.php  

notify: restart nginx  

# 重启nginx  

handlers:  

- name: restart nginx  

service: name=nginx state=restarted  

  2、index.php文件
  

<?php  

echo phpinfo();  

?>      

  注:安装的php版本查看
  #php -v
  PHP 5.6.31 (cli) (built: Jul6 2017 08:06:11)
  Copyright (c) 1997-2016 The PHP Group
  Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
  with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
  with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
页: [1]
查看完整版本: 使用Ansible安装部署nginx+php+mysql之安装php(2)