ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
1)创建目录 [admin@master prod]$ sudo mkdir -p /srv/salt/prod/php [admin@master prod]$ sudo mkdir -p /srv/salt/prod/php/files 2)下载软件及拷贝启动脚本和配置文件 [admin@master files]$ sudo wget http://cn2.php.net/distributions/php-7.1.14.tar.gz 然后找一台机器安装一下,如如下几个文件拷贝到files目录下 配置文件2个 #/usr/local/php-7.1.14/etc -rw-r--r-- 1 root root 4495 Jan 25 18:55 php-fpm.conf.default -rw-r--r-- 1 root root 18538 Jan 25 18:55 www.conf.default #启动脚本 #/usr/local/src/php-7.1.14/sapi/fpm -rw-rw-r--. 1 root root 2390 Jan 31 03:05 init.d.php-fpm.in php.ini文件 #/usr/local/src/php-7.1.14/ -rw-rw-r--. 1 root root 71096 Jan 31 03:05 php.ini-product 最后在该目录下的文件如下 [admin@master files]$ ll total 19076 -rw-r--r--. 1 root root 2568 Jan 30 16:19 init.d.php-fpm.in -rw-r--r--. 1 root root 19426882 Feb 1 2018 php-7.1.14.tar.gz -rw-r--r--. 1 root root 4495 Jan 30 16:13 php-fpm.conf.default -rw-r--r--. 1 root root 71096 Jan 30 16:44 php.ini-production -rw-r--r--. 1 root root 18536 Jan 30 16:26 www.conf.default 接下我们需要修改一下 第一步: 修改启动脚本 #prefix=@prefix@ prefix=/usr/local/php-7.1.14 #exec_prefix=@exec_prefix@ exec_prefix=${prefix} #php_fpm_BIN=@sbindir@/php-fpm php_fpm_BIN=${exec_prefix}/sbin/php-fpm #php_fpm_CONF=@sysconfdir@/php-fpm.conf php_fpm_CONF=${prefix}/etc/php-fpm.conf #php_fpm_PID=@localstatedir@/run/php-fpm.pid php_fpm_PID=${prefix}/var/run/php-fpm.pid 第二步: 修改www.conf.default配置文件 ;user = nobody ;group = nobody user = web group = web listen = 127.0.0.1:9000 根据实际情况调整一下一下几个参数,以下是参考 pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 10 pm.max_spare_servers = 30 pm.max_requests = 50000 二)编写安装php的sls文件 ~~~ [admin@master php]$ cat install.sls include: - pkg.pkg-init - user.web - zlib.install pkg-php: pkg.installed: - names: - mysql-devel - openssl-devel - swig - libjpeg-turbo - libjpeg-turbo-devel - libpng - libpng-devel - freetype - freetype-devel - libxml2 - libxml2-devel - libcurl - libcurl-devel php-source-install: file.managed: - name: /usr/local/src/php-7.1.14.tar.gz - source: salt://php/files/php-7.1.14.tar.gz - user: root - group: root - mode: 755 cmd.run: - name: cd /usr/local/src && sudo tar xf php-7.1.14.tar.gz && cd php-7.1.14 && sudo ./configure --prefix=/usr/local/php-7.1.14 --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-jpeg-dir --with-png-dir --with-zlib=/usr/local/src/zlib-1.1.12 --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-7.1.14/etc --enable-fpm --with-fpm-user=web --with-fpm-group=web && sudo make && sudo make install - unless: test -d /usr/local/php-7.1.14 - require: - file: php-source-install - pkg: pkg-php - user: web-user-group php-ini: file.managed: - name: /usr/local/php-7.1.14/etc/php.ini - source: salt://php/files/php.ini-production - user: root - group: root - mode: 644 php-fpm: file.managed: - name: /usr/local/php-7.1.14/etc/php-fpm.conf - source: salt://php/files/php-fpm.conf.default - user: root - group: root - mode: 644 www-conf: file.managed: - name: /usr/local/php-7.1.14/etc/php-fpm.d/www.conf - source: salt://php/files/www.conf.default - user: root - group: root - mode: 644 php-service: file.managed: - name: /etc/init.d/php-fpm - source: salt://php/files/init.d.php-fpm.in - user: root - group: root - mode: 755 cmd.run: - name: chkconfig --add php-fpm - unless: chkconfig --list|grep php-fpm - require: - file: php-service service.running: - name: php-fpm - enable: True - reload: True - require: - cmd: php-service - watch: - file: php-ini - file: php-fpm - file: www-conf ~~~ 接下就测试 [admin@master php]$ sudo salt 'proxy01*' state.sls php.install env=prod test=true Summary ------------- Succeeded: 36 (unchanged=12, changed=5) Failed: 0 ------------- Total states run: 36 没有问题就安装 [admin@master php]$ sudo salt 'proxy01*' state.sls php.install env=prod