使用Ansible安装部署nginx+php+mysql之安装php(2)
二、使用Ansible安装php
1、php.yaml文件内容
1 - hosts: clong
2 remote_user: root
3 gather_facts: no
4 tasks:
5 # 安装libselinux-python
6 - name: isntall libselinux-python
7 yum: name=libselinux-python state=present
8 # 安装epel源
9 - name: install epel-release repo
10 yum: name=epel-release state=present
11 # 安装rpm包
12 - name: install remote php rpm
13 yum: name=http://rpms.famillecollet.com/enterprise/remi-release-7.rpm state=present
14 # 安装php5.6
15 - name: install php
16 yum: name={{ item }} state=present enablerepo=remi enablerepo=remi-php56
17 with_items:
18 - php
19 - php-opcache
20 - php-devel
21 - php-mbstring
22 - php-mcrypt
23 - php-mysqlnd
24 - php-phpunit-PHPUnit
25 - php-pecl-xdebug
26 - php-pecl-xhprof
27 - php-mysql
28 - php-pecl-apcu
29 - php-pdo
30 - php-pear
31 - php-fpm
32 - php-cli
33 - php-xml
34 - php-bcmath
35 - php-process
36 - php-gd
37 - php-common
38 - php-json
39 - php-pdo_dblib
40 - php-pgsql
41 - php-recode
42 - php-snmp
43 - php-soap
44 - php-pecl-zip
45 - libjpeg*
46 - php-imap
47 - php-ldap
48 - php-odbc
49 - php-xmlrpc
50 - php-mbstring
51 - php-bcmath
52 - php-mhash
53 - libmcrypt
54 - libmcrypt-devel
55 # 开启php-fpm
56 - name: start php-fpm
57 service: name=php-fpm state=started enabled=yes
58 # 复制index.php文件到网站根目录
59 - name: copy index.php
60 copy: src=index.php dest=/usr/share/nginx/html/index.php
61 notify: restart nginx
62 # 重启nginx
63 handlers:
64 - name: restart nginx
65 service: name=nginx state=restarted
2、index.php文件
1 <?php
2 echo phpinfo();
3 ?>
注:安装的php版本查看
#php -v
PHP 5.6.31 (cli) (built: Jul 6 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