ansible源码安装lnmp

  • hosts: all
    remote_user: root
    tasks:
    • name: yum
      yum: name=gcc,gcc-c++,epel-release,libxml2-devel,gd,libjpeg-devel,libpng-devel,bison,cmake,ncurses-devel,zlib-devel,pcre-devel,openssl-devel
    • name: tar my
      unarchive: src=/root/mysql-5.5.22.tar.gz dest=/usr/src
    • name: cmake my
      shell: cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc && make -j4 && make install
      args:
      chdir: /usr/src/mysql-5.5.22
    • name: useradd my
      user: name=mysql shell=/sbin/nologin create_home=no
    • name: file owner
      file: path=/usr/local/mysql owner=mysql group=mysql
    • name: link lib
      file: path=/usr/local/mysql/lib/libmysqlclient.so.18 state=link src=/usr/local/lib
    • name: link bin
      file: path=/usr/local/mysql/bin/* state=link src=/usr/bin
    • name: cp my.cnf
      copy: src=/usr/src/mysql-5.5.22/support-files/my-large.cnf dest=/etc/my.cnf remote_src=yes
    • name: cp mysqld
      copy: src=/usr/src/mysql-5.5.22/support-files/mysql.server dest=/etc/init.d/mysqld remote_src=yes
    • name: chmod mysqld
      file: path=/etc/init.d/mysqld mode=0755
    • name: support
      shell: /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
      args:
      chdir: /usr/src/mysql-5.5.22/support-files
    • name: start mysqld
      shell: /etc/init.d/mysqld start
    • name: user
      user: name=nginx shell=/sbin/nologin create_home=no
    • name: yum
      yum: name=gcc,gcc-c++,zlib-devel,pcre-devel,openssl-devel
    • name: tar nginx
      unarchive: src=/root/nginx-1.15.4.tar.gz dest=/usr/src
    • name: configure nginx
      shell: ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module && make && make install
      args:
      chdir: /usr/src/nginx-1.15.4
    • name: link
      file: src=/usr/local/nginx/sbin/nginx dest=/usr/sbin/nginx state=link
    • name: start nginx
      shell: nginx
    • name: unarchive
      unarchive: src=/root/php-7.2.0.tar.gz dest=/root/
    • name: shell configure
      shell: ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mbstring --with-gd --with-zlib --with-jpeg-dir=/usr/lib --enable-fpm && make && make install
      args:
      chdir: /root/php-7.2.0
    • name: copy php.ini
      copy: src=/root/php-7.2.0/php.ini-development dest=/usr/local/php/php.ini remote_src=yes
    • name: replace
      replace: path=/usr/local/php/php.ini regexp=‘short_open_tag = Off’ replace=‘short_open_tag = On’
    • name: copy php-fpm
      copy: src=/root/php-7.2.0/sapi/fpm/init.d.php-fpm dest=/etc/init.d/php-fpm remote_src=yes
    • name: file modify the properties
      file: path=/etc/init.d/php-fpm mode=0755 state=file
    • name: copy php-fpm.conf
      copy: src=/usr/local/php/etc/php-fpm.conf.default dest=/usr/local/php/etc/php-fpm.conf remote_src=yes
    • name: replace
      replace: path=/usr/local/php/etc/php-fpm.conf regexp=’;pid = run/php-fpm.pid’ replace=‘pid = run/php-fpm.pid’
    • name: replace
      replace: path=/usr/local/php/etc/php-fpm.conf regexp=’;emergency_restart_interval = 10’ replace=‘emergency_restart_interval = 20s’
    • name: replace
      replace: path=/usr/local/php/etc/php-fpm.conf regexp=’;error_log = log/php-fpm.log’ replace=‘error_log = log/php-fpm.log’
    • name: replace
      replace: path=/usr/local/php/etc/php-fpm.conf regexp=’;emergency_restart_threshold = 0’ replace=‘emergency_restart_threshold = 10’
    • name: replace
      replace: path=/usr/local/php/etc/php-fpm.conf regexp=’;process.max = 128’ replace=‘process.max = 128’
    • name: replace
      replace: path=/usr/local/php/etc/php-fpm.conf regexp=’;rlimit_files = 1024’ replace=‘rlimit_files = 1024’
    • name: replace
      replace: path=/usr/local/php/etc/php-fpm.conf regexp=’;events.mechanism = epoll’ replace=‘events.mechanism = epoll’
    • name: copy www.conf
      copy: src=/usr/local/php/etc/php-fpm.d/www.conf.default dest=/usr/local/php/etc/php-fpm.d/www.conf remote_src=yes
    • name: replace
      replace: path=/usr/local/nginx/conf/nginx.conf regexp=’ index index.html index.htm;’ replace=’ index index.php index.html index.htm;’
    • name: shell sed
      shell: sed -i ‘65,71 s/#/ /’ /usr/local/nginx/conf/nginx.conf
    • name: replace
      replace: path=/usr/local/nginx/conf/nginx.conf regexp=’ include fastcgi_params;’ replace=’ include fastcgi.conf;’
    • name: shell
      shell: /etc/init.d/php-fpm restart
    • name: service
      shell: /etc/init.d/mysqld restart
    • name: unarchive
      unarchive: src=/root/ComsenzDiscuz-DiscuzX-master.zip dest=/root
    • name: delete
      file: name=/usr/local/nginx/html/* state=absent
    • name: shell upload
      shell: cp -r /root/DiscuzX/upload /usr/local/nginx/html
    • name: file
      file: path=/usr/local/nginx/html/upload mode=0777 recurse=yes
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值