#################################################
###
Saltstack Installing the PHP client
#################################################
#相关依赖包安装
[email protected] ~]# Yum install-y libmcrypt libmcrypt-devel mhash mhash-devel php-mcrypt libmcrypt libmcrypt-devel MHA SH mhash-devel libevent libevent-devel libxml2 libxml2-devel bzip2-devel libcurl-devel libpng-devel freetype-devel Libxslt-devel net-snmp-devel readline-devel aspell-devel unixodbc-devel libicu-devel libc-client libc-client-devel Libxpm-devel libvpx-devel enchant-devel openldap openldap-devel postgresql-devel db4-devel gmp-devel sqlite-devel Pcre-devel mysql-devel openssl-devel Swig libjpeg-turbo libjpeg-turbo-devel libpng freetype zlib zlib-devel libcurl
cd/usr/local/src/&& Tar XF php-5.6.36.tar.gz && cd php-5.6.36 &&./configure--prefix=/usr/loca L/php-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
"" Installation Path "" "
--prefix=/usr/local/php \
"" "PHP.ini Configuration File path" ""
--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP/ETC \
"" Optimization Option "" "
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
"" "Enable Opcache, default is zendoptimizer+ (Zendopcache)" ""
--enable-opcache \
"" "FPM" ""
--ENABLE-FPM \
--WITH-FPM-USER=WWW \
--WITH-FPM-GROUP=WWW \
"" "MySQL" ""
--WITH-MYSQL=MYSQLND \
--WITH-MYSQLI=MYSQLND \
--WITH-PDO-MYSQL=MYSQLND \
"" Internationalization and character encoding support "" "
--with-gettext \
--enable-mbstring \
--with-iconv \
"" "Encryption Extension" ""
--with-mcrypt \
--with-mhash \
--WITH-OPENSSL \
"" "Mathematical Extension" ""
--enable-bcmath \
"" "Web Service, soap dependency libxml" ""
--ENABLE-SOAP \
--with-libxml-dir \
"" "process, signal and memory" ""
--ENABLE-PCNTL \
--ENABLE-SHMOP \
--ENABLE-SYSVMSG \
--enable-sysvsem \
--ENABLE-SYSVSHM \
"" "Socket & Curl" ""
--enable-sockets \
--with-curl \
"" "Compress and Archive" ""
--with-zlib \
--enable-zip \
--WITH-BZ2 \
"" "GNU Readline command line shortcut key binding" "
--with-readline
Mkdir-p/srv/salt/php/files/
#配置php的目录结构
[Email protected] prod]# tree/srv/salt/php/
/srv/salt/prod/php/
├──files
│?? ├──init.d.php-fpm
│?? ├──php-5.6.36.tar.gz
│?? ├──php-fpm.conf
│?? └──php.ini
└──php-install.sls
#复制配置文件到files目录
Cp/usr/local/src/php-5.6.36/php.ini-development/srv/salt/php/files/php.ini
Cp/usr/local/src/php-5.6.36/sapi/fpm/php-fpm.conf/srv/salt/php/files/php-fpm.conf
cp/usr/local/src/php-5.6.36/sapi/fpm/init.d.php-fpm/srv/salt/php/files/init.d.php-fpm
#php-install.sls,php Master configuration file
[Email protected] ~]# Cat/srv/salt/php/php-install.sls
PHP-PKG:
Pkg.installed:
- pkgs:
- libmcrypt
- libmcrypt-devel
- mhash
- mhash-devel
- php-mcrypt
- libevent
- libevent-devel
- libxml2
- libxml2-devel
- bzip2-devel
- libcurl-devel
- libpng-devel
- freetype-devel
- libxslt-devel
- net-snmp-devel
- Readline-devel
- Aspell-devel
- Unixodbc-devel
- Libicu-devel
- libc-client
- Libc-client-devel
- Libxpm-devel
- Libvpx-devel
- Enchant-devel
- OpenLDAP
- Openldap-devel
- Postgresql-devel
- Db4-devel
- Gmp-devel
- Sqlite-devel
- Pcre-devel
- Mysql-devel
- Openssl-devel
- Swig
- Libjpeg-turbo
- Libjpeg-turbo-devel
- libpng
- FreeType
- zlib
- Zlib-devel
- Libcurl
Php_user:
User.present:
- Name:www
- Createhome:false
- Gid_from_name:true
- Shell:/sbin/nologin
Php-install:
File.managed:
- Name:/usr/local/src/php-5.6.36.tar.gz
- Source:salt://php/files/php-5.6.36.tar.gz
- User:root
- Group:root
- mode:755
Cmd.run:
- name:cd/usr/local/src/&& Tar XF php-5.6.36.tar.gz && cd php-5.6.36 &&./configure--prefix=/usr /local/php-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
- Unless:test-d/usr/local/php
- Require
- Pkg:php-pkg
- File:php-install
Php_conf:
File.managed:
- Name:/usr/local/php/etc/php.ini
- Source:salt://php/files/php.ini
- User:root
- Group:root
- mode:644
Php_server_conf:
File.managed:
- Name:/usr/local/php/etc/php-fpm.conf
- Source:salt://php/files/php-fpm.conf
- User:root
- Group:root
- mode:644
Php_chkconfig:
File.managed:
- Name:/ETC/INIT.D/PHP-FPM
- source:salt://php/files/init.d.php-fpm
- User:root
- Group:root
- mode:755
Cmd.run:
- Names
- Chkconfig--add PHP-FPM
- Chkconfig PHP-FPM on
- Service PHP-FPM Start
- Unless:chkconfig--list | grep php-fpm
- Require
- File:php_chkconfig
Php-service:
Service.running:
- name:php-fpm
- Enable:true
- Require
- Watch
#客户端安装php
[Email protected]]# Salt ' M01 ' State.sls php.php-install
Saltstack Installing the PHP client