这里的安装包括了两个插件安装 memcache和zendopcache,但是没有更改php.ini的内容,到时候直接把修改过的文件直接替换就好了。


测试,可以自定义版本和安装路径,但是版本的话需要softurl里面有才能定义,不能只能用wget

sudo salt '192.168.1.1' state.sls php.install saltenv="ot" pillar='{php:{"installdir":"/usr/local/php--test","phpinidir":"/tmp/phpini-test/","apachedir":"/usr/local/apache-test","version":"5.4.45"}}'


{% set softurl =  "http://1.1.1.1/saltsoftware/" %}
{% set installdir = salt['pillar.get']('php:installdir', '/usr/local/php') %}
{% set phpinidir = salt['pillar.get']('php:phpinidir', '/etc') %}
{% set apachedir = salt['pillar.get']('php:apachedir', '/usr/local/apache2') %}
{% set version = salt['pillar.get']('php:version', '5.4.45') %}

php_inidir:
  cmd.run:
    - names:
      - mkdir ` phpinidir `
    - unless: test -e ` phpinidir `

php_software:
  cmd.run:
    - cwd: /root/soft
    - name: wget ` softurl `/php-` version `.tar.gz
    - unless: test -e /root/soft/php-` version `.tar.gz

php_ln:
  cmd.run:
    - name: ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so && ln -s /usr/lib64/libpng.so /usr/lib/libpng.so && ln -s /usr/lib64/libgd.so /usr/lib/libgd.so
    - unless: test -e /usr/lib/libjpeg.so && test -e /usr/lib/libgd.so && test -e /usr/lib/libpng.so

php_install:
  cmd.run:
    - name: cd /root/soft && tar -zvxf php-` version `.tar.gz &&  cd php-` version ` && ./configure --prefix=` installdir ` --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=` apachedir `/bin/apxs --with-gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-zlib --with-openssl --enable-sockets --enable-mbstring --with-bz2 --enable-ftp --with-gettext --enable-sysvshm --enable-shmop --enable-gd-native-ttf --enable-gd-jis-conv --with-curl --with-config-file-path=` phpinidir ` && make -j 4 && make install && cp php.ini-development ` phpinidir `
    - unless: test -e ` installdir `

memcache_software:
  cmd.run:
    - cwd: /root/soft
    - name: wget ` softurl `/memcache-2.2.7.tgz
    - unless: test -e /root/soft/memcache-2.2.7.tgz

memcache_install:
  cmd.run:
    - name: cd /root/soft && tar -zvxf memcache-2.2.7.tgz &&  cd memcache-2.2.7 && ` installdir `/bin/phpize && ./configure --with-php-config={{ installdir  }}/bin/php-config && make && make install
    - unless: php_install

zendopcache_software:
  cmd.run:
    - cwd: /root/soft
    - name: wget ` softurl `/zendopcache-7.0.4.tgz
    - unless: test -e /root/soft/zendopcache-7.0.4.tgz

zendopcache_install:
  cmd.run:
    - name: cd /root/soft && tar -zvxf zendopcache-7.0.4.tgz &&  cd zendopcache-7.0.4 && ` installdir `/bin/phpize  && ./configure --with-php-config={{ installdir  }}/bin/php-config && make && make install
    - unless: php_install