---
- hosts: 10.0.0.171
gather_facts: no
vars:
phpver: php-7.4.20
phpsrc: "{{phpver}}.tar.gz"
dir: /data/php
libgdver: libgd-2.3.1
libgdsrc: libgd-2.3.1.tar.gz
tasks:
- name: install necessary packs
yum:
name:
- libxml2
- libxml2-devel
- openssl
- openssl-devel
- bzip2
- bzip2-devel
- libcurl
- libcurl-devel
- libjpeg
- libjpeg-devel
- libpng
- libpng-devel
- freetype
- freetype-devel
- gmp
- gmp-devel
- libmcrypt
- libmcrypt-devel
- readline
- readline-devel
- libxslt
- libxslt-devel
- libsqlite3x-devel
- oniguruma-devel
- rsync
- name: download php and unarchive
unarchive: remote_src=no src={{phpsrc}} dest=/usr/local/src
register: var1
until: var1 is succeeded
- name: download libgd and unarchive
unarchive: remote_src=no src={{libgdsrc}} dest=/usr/local/src
register: var2
until: var2 is succeeded
retries: 5
- name: compile libgd
shell: |
chdir=/usr/local/src/{{libgdver}}
./configure --prefix=/usr/local/{{libgdver}}
make -j 4
make install
- name: make dir {{dir}}
file: path={{dir}} state=directory
- name: configure
shell: |
chdir=/usr/local/src/{{phpver}}
export PKG_CONFIG_PATH=/usr/local/{{libgdver}}/lib/pkgconfig
./configure \
--prefix={{dir}} \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--enable-gd \
--with-external-gd \
--enable-gd-jis-conv \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-zlib \
--with-freetype \
--with-jpeg \
--with-curl \
--enable-mbstring \
--enable-xml \
--enable-sockets \
--enable-fpm \
--enable-maintainer-zts \
--disable-fileinfo
make -j 4 && make install
- name: path1
copy:
content: "PATH={{dir}}/bin:/apps/httpd/bin:$PATH"
dest: /etc/profile.d/lamp.sh
- name: path2
shell: . /etc/profile.d/lamp.sh
- name: prepare etc and service
synchronize: src="{{item.src}}" dest="{{item.dest}}"
loop:
- {src: "/usr/local/src/{{phpver}}/php.ini-production" , dest: /etc/php.ini }
- {src: "/usr/local/src/{{phpver}}/sapi/fpm/php-fpm.service" , dest: /usr/lib/systemd/system/}
- {src: "{{dir}}/etc/php-fpm.conf.default" , dest: "{{dir}}/etc/php-fpm.conf"}
- {src: "{{dir}}/etc/php-fpm.d/www.conf.default" , dest: "{{dir}}/etc/php-fpm.d/www.conf"}
delegate_to: "{{ inventory_hostname }}"
- name: edit php-fpm1
lineinfile: path="{{dir}}/etc/php-fpm.d/www.conf" regexp="^user" line="user = apache"
- name: edit php-fpm2
lineinfile: path="{{dir}}/etc/php-fpm.d/www.conf" regexp="^group" line="group = apache"
- name: edit php-fpm3
lineinfile: path="{{dir}}/etc/php-fpm.d/www.conf" regexp="^;pm\.status_path.*" line="pm.status_path = /fpm_status"
- name: edit php-fpm4
replace: path="{{dir}}/etc/php-fpm.d/www.conf" regexp="^;(ping\.path.*)" replace="\1"
- name: mkdir /etc/php.d
file: name=/etc/php.d state=directory
- name: opcache
copy:
content: |
[opcache]
zend_extension=opcache.so
opcache.enable=1
dest: /etc/php.d/opcache.ini
- name: start service
service: name=php-fpm state=started enabled=yes