Saltstack Deployment nginx+php

Source: Internet
Author: User
Tags fpm install php mcrypt stop script zts saltstack

Because basically the production environment is a nginx+php environment, it is not a separate list of salt deployment PHP process, this is combined with my script in the production environment nginx+php environment deployment.

Deployment planning:

1) Compile and install Libiconv, Libmcrypt, Mhash, and MCrypt

2) Compile and install PHP

3) add start Stop script

4) Add to system service and set boot up

5) Copy log cut script

6) Add Log cutting Timer task

7) Install MEMCACHED/REDIS/PROTOBUF extension

8) Modify php.ini load PHP extension

Salt Deployment Directory Schema:

[[email protected] ~]# tree /srv/salt/base//srv/salt/base/├── cron│    ├── files│   │   ├── nginx_cut_log.sh│   │    └── php_cut_log.sh│   ├── nginx.sls│   └── php.sls├──  Nginx│   ├── files│   │   ├── nginx│   │    ├── nginx-1.6.3.tar.gz│   │   └── nginx.conf│    ├── install.sls│   └── service.sls├── packages│   └──  install.sls├── pcre│   ├── files│   │   └──  Pcre-8.37.tar.gz│   └── install.sls├── php│   ├── extension.sls│    ├── files│   │   ├── libmemcached-1.0.18.tar.gz│    │   ├── memcached-2.2.0.tgz│   │   ├──  php-5.6.16.tar.gz│   │   ├── php-fpm│   │    ├── php-fpm.conf│   │   ├── php.ini│   │    ├── phpredis-2.2.4.tar.gz│   │   └── protobuf.so│    ├── install.sls│   ├── libiconv│   │   └──  files│   │       └── libiconv-1.14.tar.gz│    ├── libiconv.sls│   ├── libmcrypt│   │   └──  files│   │       └── libmcrypt-2.5.8.tar.gz│    ├── libmcrypt.sls│   ├── mcrypt│   │    └── files│   │       └── mcrypt-2.6.8.tar.gz│   ├── mcrypt.sls│    ├── mhash│   │   └── files│   │        └── mhash-0.9.9.9.tar.gz│   ├── mhash.sls│    └── service.sls├── top.sls└── user    ├── nginx.sls     └── php.sls18 directories, 34 files

Install Libiconv:

[[email protected] base]# cat php/libiconv.sls libiconv-source-install:   file.managed:    - name: /opt/tools/libiconv-1.14.tar.gz     - source: salt://php/libiconv/files/libiconv-1.14.tar.gz    - user:  root    - group: root    - mode: 755   cmd.run:    - name: cd /opt/tools/ && tar -zxf  Libiconv-1.14.tar.gz && cd libiconv-1.14 && ./configure --prefix =/usr/local && make && make install && /sbin/ ldconfig     - unless: test -e /usr/local/lib/libiconv.so.2.5.1     - require:      - file:  Libiconv-source-install

Install Limcrypt:

[[email protected] base]# cat php/libmcrypt.sls libmcrypt-source-install:   file.managed:    - name: /opt/tools/libmcrypt-2.5.8.tar.gz     - source: salt://php/libmcrypt/files/libmcrypt-2.5.8.tar.gz    - user : root    - group: root    - mode: 755   cmd.run:    - name: cd /opt/tools && tar -zxf  libmcrypt-2.5.8.tar.gz && cd libmcrypt-2.5.8 && ./configure  && make && make install && ldconfig & & cd libltdl && ./configure --enable-ltdl-install &&  make && make install && /sbin/ldconfig    -  unless: test -e /usr/local/lib/libmcrypt.so.4.4.8    - require:       - file: libmcrypt-source-install

Install Mhash:

[[email protected] base]# cat php/mhash.sls mhash-source-install:   file.managed:    - name: /opt/tools/mhash-0.9.9.9.tar.gz     - source: salt://php/mhash/files/mhash-0.9.9.9.tar.gz    - user: root     - group: root    - mode: 755   cmd.run:    - name: cd /opt/tools/ && tar -zxf  mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9 && ./configure & & make && make install && ln -s /usr/local/lib/ libmcrypt.la /usr/lib/libmcrypt.la && ln -s /usr/local/lib/libmcrypt.so  /usr/lib/libmcrypt.so && ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/ Libmcrypt.so.4 && ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8 && ln  -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a && ln -s /usr/local/lib /libmhash.la /usr/lib/libmhash.la && ln -s /usr/local/lib/libmhash.so / usr/lib/libmhash.so && ln -s /usr/local/lib/libmhash.so.2 /usr/lib/ libmhash.so.2 && ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/ libmhash.so.2.0.1 && ln -s /usr/local/bin/libmcrypt-config /usr/bin/ libmcrypt-config    - unless: test -e /usr/local/lib/libmhash.a     - require:      - file: mhash-source-install

Install MCrypt:

[[email protected] base]# cat php/mcrypt.sls  mcrypt-source-install:  file.managed:    - name: /opt/tools/ Mcrypt-2.6.8.tar.gz    - source: salt://php/mcrypt/files/mcrypt-2.6.8.tar.gz     - user: root    - group: root     - mode: 644  cmd.run:    - name: cd /opt/ tools/ && tar -zxf mcrypt-2.6.8.tar.gz && cd mcrypt-2.6.8  && /sbin/ldconfig && ./configure && make & & make install    - unless: test -e /usr/local/bin/ mcrypt    - require:      - file:  Mcrypt-source-install 

Install PHP:

[[email protected] base]# cat php/install.sls include:  -  Packages.install  - user.php  - php.libiconv  - php.libmcrypt   - php.mhash  - php.mcryptphp-source-install:  file.managed:     - name: /opt/tools/php-5.6.16.tar.gz    - source:  salt://php/files/php-5.6.16.tar.gz    - user: root    -  group: root    - mode: 755  cmd.run:     - name: cd /opt/tools/ && tar -zxf php-5.6.16.tar.gz  && cd php-5.6.16 && ./configure --prefix=/usr/local/php -- with-config-file-path=/usr/local/php/etc --with-libxml-dir --enable-xml --enable-fpm -- With-fpm-user=www --with-fpm-group=www --enAble-bcmath --enable-mbstring --enable-gd-native-ttf --enable-sockets --enable-mysqlnd  --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-zip -- enable-inline-optimization --with-gd --with-bz2 --with-zlib --with-mcrypt -- with-mhash --with-openssl --with-xmlrpc --with-iconv-dir --with-freetype-dir -- with-jpeg-dir --with-png-dir --without-pear --disable-ipv6 --disable-pdo -- with-gettext --disable-debug --without-pdo-sqlite --disable-rpath --enable-shmop -- enable-sysvsem --with-curl --with-curlwrappers --enable-mbregex --enable-pcntl -- enable-soap --enable-sigchild --enable-pdo && make zend_extra_libs= '-liconv '  && make install    - unless: test -d /usr/ Local/php    - require:      - file: php-source-install      -  user: php-user-group      - cmd: libiconv-source-install       - cmd: libmcrypt-source-install       - cmd: mcrypt-source-install      - cmd:  Mhash-source-install

To configure the PHP service:

[[Email protected] base]# cat php/service.sls include:  - php.install   - cron.php/usr/local/php/etc:  file.directory:    - user:  www    - group: www    - mode: 644     - makedirs: True/usr/local/php/etc/php-fpm.conf:  file.managed:     - source: salt://php/files/php-fpm.conf    - user:  Www    - group: www    - mode: 644/etc/php.ini:   file.managed:    - source: salt://php/files/php.ini     - user: www    - group: www    -  mode: 644/etc/profile:  file.append:    - text:       - export&nBsp Path= $PATH:/usr/local/php/bin:/usr/local/php/sbinphp-init:  file.managed:    -  name: /etc/init.d/php-fpm    - source: salt://php/files/php-fpm     - user: root    - group: root     - mode: 755  cmd.run:    - name: chkconfig --add  php-fpm && source /etc/profile    - unless:  chkconfig --list|grep php-fpm    - require:       - file: php-initphp-service:  service.running:    - name:  php-fpm    - enable: true    - restart: true     - require:      - cmd: php-init     - watch:      - file: /etc/php.ini      -  file: /usr/local/php/etc/php-fpm.conf

To deploy a scheduled task:

[email protected] base]# cat Cron/php.sls php-crond-job:file.managed:-Name:/opt/tools/scripts/php_cut_log.sh- Source:salt://cron/files/php_cut_log.sh-user:root-group:root-mode:755/bin/bash/opt/tools/scripts/php_ cut_log.sh >/dev/null 2>&1:cron.present:-identifier:cut PHP daily logs Job-user:root-minute: ' 0 '-hour: ' 0 '-require:-File:php-crond-job

To install the PHP extension:

[[email protected] base]# cat php/extension.sls include:  -  Php.servicelibmemcached-source-install:  file.managed:    - name: /opt /tools/libmemcached-1.0.18.tar.gz    - source: salt://php/files/ Libmemcached-1.0.18.tar.gz    - user: root    - group:  root    - mode: 644  cmd.run:    - name : cd /opt/tools && tar -zxf libmemcached-1.0.18.tar.gz &&  cd libmemcached-1.0.18 && ./configure --prefix=/usr/local/libmemcached  --with-memcached && make && make install    -  unless: test -d /usr/local/libmemcached    - require:       - file: libmemcached-source-installmemcached-source-install:  file.managed:    -  name: /opt/tools/memcached-2.2.0.tgz    - source: salt://php/files/ memcached-2.2.0.tgz    - user: root    - group:  Root    - mode: 644  cmd.run:    - name:  cd /opt/tools/ && tar -zxf memcached-2.2.0.tgz && cd  memcached-2.2.0 && /usr/local/php/bin/phpize && ./configure -- enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/ libmemcached && make && make install    -  unless: test -x /usr/bin/memcached    - require:       - file:  Memcached-source-installphpredis-source-install:  file.managed:    - name:  /opt/tools/phpredis-2.2.4.tar.gz    - source: salt://php/files/ phpredis-2.2.4.tar.gz    - user: root    - group:  Root    - mode: 644  cmd.run:    - name:  cd /opt/tools && tar -zxf phpredis-2.2.4.tar.gz && cd  phpredis-2.2.4 && /usr/local/php/bin/phpize && ./configure -- With-php-config=/usr/local/php/bin/php-config && make && make install     - unless: test -e /usr/local/php/lib/php/extensions/ no-debug-non-zts-20131226/redis.so    - require:      -  file: phpredis-source-installprotobuf-extension:  file.managed:    - name: /usr/local/php/lib/php/ extensions/no-debug-non-zts-20131226/protobuf.so    - source: salt://php/files/ protobuf.so    - user: www    - group: www     - mode: 755extension-init:  file.managed:    -  Name: /usr/local/php/etc/php.ini    - source: salt://php/files/php.ini     - user: www    - group: www     - replace: True    - mode: 644  cmd.run:     - name: chown -R www:www /usr/local/php && source  /etc/profile    - require:      - file:  protobuf-extension      - file: extension-init    - watch:        - file: /usr/local/php/etc/php.ini

Top.sls file:

[email protected] base]# cat Top.sls base: ' salt-minion02.contoso.com ':-Nginx.service-php.service-php.ext Ension


This article is from "it Little two lang" blog, please make sure to keep this source http://jerry12356.blog.51cto.com/4308715/1934153

Saltstack Deployment nginx+php

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.