352262 发表于 2018-11-4 07:31:55

4.4 salt memcahe PHP+memcahce/redis nginx

  安装memcahe
  # cd /srv/salt/prod/
  # mkdir -p memcache/files
  # cd memcache/files/
  # cp memcached-1.4.24.tar.gz /usr/local/src/
  # vim install.sls
  include:
  - libevent.install                              # 将libevent文件包含进来
  memcached-source-install:
  file.managed:
  - name: /usr/local/src/memcached-1.4.24.tar.gz
  - source: salt://memcached/files/memcached-1.4.24.tar.gz
  - user: root
  - group: root
  - mode: 644
  cmd.run:
  - name: cd /usr/local/src && tar zxf memcached-1.4.24.tar.gz && cd memcached-1.4.24&& ./configure --prefix=/usr/local/memcached --enable-64bit --with-libevent=/usr/local/libevent && make && make install
  - unless: test -d /usr/local/memcached
  - require:
  - cmd: libevent-source-install                # libevent的ID
  - file: memcached-source-install
  安装pcre
  # mkdir /srv/salt/prod/pcre/files -p
  # cd /srv/salt/prod/pcre/files/
  # cp pcre-8.37.tar.gz/usr/local/src/
  # cd /srv/salt/prod/pcre
  # cat install.sls
  pcre-source-install:
  file.managed:
  - name: /usr/local/src/pcre-8.37.tar.gz
  - source: salt://pcre/files/pcre-8.37.tar.gz
  - user: root
  - group: root
  - mode: 755
  cmd.run:
  - name: cd /usr/local/src && tar zxf pcre-8.37.tar.gz && cd pcre-8.37 && ./configure --prefix=/usr/local/pcre && make && make install
  - unless: test -d /usr/local/pcre
  - require:
  - file: pcre-source-install
  安装nginx
  # mkdir -p /srv/salt/prod/nginx/files
  # cd /srv/salt/prod/nginx/files/
  # cp nginx-1.9.1.tar.gz /usr/local/src/
  # cat install.sls
  include:
  - pcre.install
  - user.www
  - pkg.pkg-init
  nginx-source-install:
  file.managed:
  - name: /usr/local/src/nginx-1.9.1.tar.gz
  - source: salt://nginx/files/nginx-1.9.1.tar.gz
  - user: root
  - group: root
  - mode: 755
  cmd.run:
  - name: cd /usr/local/src && tar zxf nginx-1.9.1.tar.gz && cd nginx-1.9.1&& ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-http_dav_module --with-pcre=/usr/local/src/pcre-8.37 && make && make install && chown -R www:www /usr/local/nginx
  - unless: test -d /usr/local/nginx
  - require:
  - user: www-user-group
  - file: nginx-source-install
  - pkg: pkg-init
  - cmd: pcre-source-install
  # cat service.sls
  include:
  - nginx.install
  nginx-init:
  file.managed:
  - name: /etc/init.d/nginx
  - source: salt://nginx/files/nginx-init
  - mode: 755
  - user: root
  - group: root
  cmd.run:
  - name: chkconfig --add nginx
  - unless: chkconfig --list | grep nginx
  - require:
  - file: nginx-init
  /usr/local/nginx/conf/nginx.conf:
  file.managed:
  - source: salt://nginx/files/nginx.conf
  - user: www
  - group: www
  - mode: 644
  nginx-service:
  file.directory:
  - name: /usr/local/nginx/conf/vhost
  - require:
  - cmd: nginx-source-install
  service.running:
  - name: nginx
  - enable: True

  ->  - require:
  - cmd: nginx-init
  - watch:
  - file: /usr/local/nginx/conf/nginx.conf
  # tree
  .
  ├── files
  │   ├── nginx-1.9.1.tar.gz
  │   ├── nginx.conf
  │   └── nginx-init
  ├── install.sls
  └── service.sls
  PHP+memcahce/redis的安装
  基础环境
  # mkdir /srv/salt/prod/php/files -p
  # cd /srv/salt/prod/php/files/
  # ll
  总用量 18120
  -rw-r--r-- 1 root root   2362 11月 14 23:06 init.d.php-fpm
  -rw-r--r-- 1 root root    36459 11月 14 23:06 memcache-2.2.7.tgz
  -rw-r--r-- 1 root root 18281659 11月 14 23:06 php-5.6.9.tar.gz
  -rw-r--r-- 1 root root    22252 11月 14 23:06 php-fpm.conf.default
  -rw-r--r-- 1 root root    69599 11月 14 23:06 php.ini-production
  -rw-r--r-- 1 root root   134340 11月 14 23:06 redis-2.2.7.tgz
  安装文件
  # cd ..
  # vim install.sls
  pkg-php:
  pkg.installed:
  - names:
  - mysql-devel
  - openssl-devel
  - swig
  - libjpeg-turbo
  - libjpeg-turbo-devel
  - libpng
  - libpng-devel
  - freetype
  - freetype-devel
  - libxml2
  - libxml2-devel
  - zlib
  - zlib-devel
  - libcurl
  - libcurl-devel
  php-source-install:
  file.managed:
  - name: /usr/local/src/php-5.6.9.tar.gz
  - source: salt://php/files/php-5.6.9.tar.gz
  - user: root
  - group: root
  - mode: 755
  cmd.run:
  - name: cd /usr/local/src && tar zxf php-5.6.9.tar.gz && cd php-5.6.9&&./configure --prefix=/usr/local/php-fastcgi --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-jpeg-dir --with-png-dir --with-zlib --enable-xml--with-libxml-dir --with-curl --enable-bcmath --enable-shmop --enable-sysvsem--enable-inline-optimization --enable-mbregex --with-openssl --enable-mbstring --with-gd --enable-gd-native-ttf --with-freetype-dir=/usr/lib64 --with-gettext=/usr/lib64 --enable-sockets --with-xmlrpc --enable-zip --enable-soap --disable-debug --enable-opcache --enable-zip --with-config-file-path=/usr/local/php-fastcgi/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www && make && make install
  - require:
  - file: php-source-install
  - user: www-user-group
  - unless: test -d /usr/local/php-fastcgi
  pdo-plugin:
  cmd.run:
  - name: cd /usr/local/src/php-5.6.9/ext/pdo_mysql/ && /usr/local/php-fastcgi/bin/phpize && ./configure --with-php-config=/usr/local/php-fastcgi/bin/php-config &&make&& make install
  - unless: test -f /usr/local/php-fastcgi/lib/php/extensions/*/pdo_mysql.so
  - require:
  - cmd: php-source-install
  php-ini:
  file.managed:
  - name: /usr/local/php-fastcgi/etc/php.ini
  - source: salt://php/files/php.ini-production
  - user: root
  - group: root
  - mode: 644
  php-fpm:
  file.managed:
  - name: /usr/local/php-fastcgi/etc/php-fpm.conf
  - source: salt://php/files/php-fpm.conf.default
  - user: root
  - group: root
  - mode: 644
  php-fastcgi-service:
  file.managed:
  - name: /etc/init.d/php-fpm
  - source: salt://php/files/init.d.php-fpm
  - user: root
  - group: root
  - mode: 755
  cmd.run:
  - name: chkconfig --add php-fpm
  - unless: chkconfig --list | grep php-fpm
  - require:
  - file: php-fastcgi-service
  service.running:
  - name: php-fpm
  - enable: True
  - require:
  - cmd: php-fastcgi-service
  - watch:
  - file: php-ini
  - file: php-fpm
  memcache
  # cat php-memcache.sls
  memcache-plugin:
  file.managed:
  - name: /usr/local/src/memcache-2.2.7.tgz
  - source: salt://php/files/memcache-2.2.7.tgz
  - user: root
  - group: root
  - mode: 755
  cmd.run:
  - name: cd /usr/local/src && tar zxf memcache-2.2.7.tgz && cd memcache-2.2.7&& /usr/local/php-fastcgi/bin/phpize && ./configure --enable-memcache --with-php-config=/usr/local/php-fastcgi/bin/php-config &&make&& make install
  - unless: test -f /usr/local/php-fastcgi/lib/php/extensions/*/memcache.so
  require:
  - file: memcache-plugin
  - cmd: php-install
  /usr/local/php-fastcgi/etc/php.ini:
  file.append:
  - text:
  - extension=memcache.so
  redis
  # cat php-redis.sls
  redis-plugin:
  file.managed:
  - name: /usr/local/src/phpredis-2.2.7.tgz
  - source: salt://php/files/phpredis-2.2.7.tgz
  - user: root
  - group: root
  - mode: 755
  cmd.run:
  - name: cd /usr/local/src && tar zxf phpredis-2.2.7.tgz && cd phpredis-2.2.7&& /usr/local/php-fastcgi/bin/phpize && ./configure --with-php-config=/usr/local/php-fastcgi/bin/php-config &&make&& make install
  - unless: test -f /usr/local/php-fastcgi/lib/php/extensions/*/redis.so
  require:
  - file: redis-plugin
  - cmd: php-install
  /usr/local/php-fastcgi/etc/php.ini:
  file.append:
  - text:
  - extension=redis.so

页: [1]
查看完整版本: 4.4 salt memcahe PHP+memcahce/redis nginx