234cfds1 发表于 2018-7-29 10:30:52

ansible批量一键安装lnmp环境

#php_server install  
- hosts: 172.16.1.5   根据自己主机自行定义
  
tasks:
  
    -name: yum rely on
  
      yum:name=zlib-devel,libxml2-devel,libjpeg-devel,libjpeg-turbo-devel,freetype-devel,libpng-devel,gd-devel,libcurl-devel,libxslt-devel
  
    -name: installlibiconv
  
      shell: cd /home/tools &&wget http://219.239.26.3/files/524500000A03C5BE/ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
  
    -name: decompression libiconv
  
      shell: cd /home/tools &&tar -xf libiconv-1.14.tar.gz
  
    -name: Toconfigure libiconv
  
      shell: cd /home/tools/libiconv-1.14 && ./configure --prefix=/usr/local/libiconv && make && make install
  
    - name:epel
  
      shell: wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo
  
    -name: yumlibmcrypt-devel
  
      yum: name=libmcrypt-devel,mhash,mcrypt
  
    - name: downloadphp-5.3.27
  
      shell: cd /home/tools/ && wget http://php.net/get/php-5.3.27.tar.gz/from/a/mirror
  
    -name: install php
  
      shell: cd /home/tools/ &&tar -xf php-5.3.27.tar.gz
  
    -name: softconnect
  
      shell: ln -s/application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
  
    -name: createphar.phar
  
      shell: touch /home/tools/php-5.3.27/ext/phar/phar.phar
  
    -name: intophp-5.3.27
  
      shell: cd /home/tools/php-5.3.27 && ./configure --prefix=/application/php5.3.27--with-mysql=/application/mysql --with-iconv-dir=/usr/local/libiconv--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode--enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization--with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring--with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl--enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags--enable-zend-multibyte --enable-static --with-xsl --with-fpm-user=nginx--with-fpm-group=nginx --enable-ftp && make && make install
  
    - name: Soft connection php5.3.27
  
      shell: ln -s /application/php5.3 27 /application/php
  
    -name: copyphp.ini-production
  
      shell: cp /home/tools/php-5.3.27/php.ini-production/application/php/lib/php.ini
  
    -name: into/application/php/etc/
  
      shell: cp /application/php/etc/php-fpm.conf.default/application/php/etc/php-fpm.conf
  
    -name: into/home/tools/php-5.3.27
  
      shell: cp/home/tools/php-5.3.27/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
  
    -name: Add executeauthority
  
      shell: chmod +x /etc/init.d/php-fpm
  
    -name: startphp-fpm
  
      shell: /etc/init.d/php-fpm start
页: [1]
查看完整版本: ansible批量一键安装lnmp环境