Hi 你好,欢迎访问!登录
当前位置:首页 - 自动化运维 - 正文 忍人所不忍,能人所不能。

Linux自动化工具之SaltStack安装PHP FastCGI

2020-03-06自动化运维90root399°c
A+ A-

1. 安装php目录结构

[[email protected]_210 ~]# cd /data/etc/salt/
[[email protected]_210 salt]# tree php/
php/
|-- config.sls
|-- files
|   |-- php-5.6.25.tar.gz
|   |-- php-fpm
|   |-- php-fpm.conf
|   `-- php.ini
|-- init.sls
`-- install.sls

2. 编写php安装文件

[[email protected]_210 php]# cat 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
      - libcurl
      - libcurl-devel
      - libmcrypt
      - libmcrypt-devel
      - bzip2
      - bzip2-devel
php_source:
  file.managed:
    - name: /usr/local/src/php-5.6.25.tar.gz
    - source: salt://php/files/php-5.6.25.tar.gz
    - user: root
    - group: root
php_extrace:
  cmd.run:
    - cwd: /usr/local/src
    - names:
      - tar zxf php-5.6.25.tar.gz
    - unless: test -d /data/Software/php-5.6.25
    - require:
      - pkg: pkg-php
php_compile:
  cmd.run:
    - names:
      - cd /usr/local/src/php-5.6.25 && ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-exif --disable-ipv6 --with-pear --with-curl --enable-bcmath --enable-mbstring --enable-sockets --with-gettext && make && make install
    - require:
      - file: php_source
    - unless: test -d /usr/local/php-fpm
php_plugin:
  cmd.run:
    - names:
      - cd /usr/local/src/php-5.6.25/ext/pdo_mysql/ && /usr/local/php-fpm/bin/phpize && ./configure --with-php-config=/usr/local/php-fpm/bin/php-config && make && make install
    - require:
      - cmd: php_compile

3. 编写php配置文件

[[email protected]_210 php]# cat config.sls
include:
  - php.install
php-ini:
  file.managed:
    - name: /usr/local/php-fpm/etc/php.ini
    - source: salt://php/files/php.ini
php-fpm:
  file.managed:
    - name: /usr/local/php-fpm/etc/php-fpm.conf
    - source: salt://php/files/php-fpm.conf
php-service:
  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
    - unless: chkconfig --list | grep php-fpm
    - require:
      - file: php-service
  service.running:
    - name: php-fpm
    - enable: True
    - require:
      - cmd: php-service
    - watch:
      - file: php-ini
      - file: php-fpm

4. php所需配置文件

[[email protected]_210 files]# ll php-fpm.conf php.ini  php-fpm
-rw-r--r-- 1 root root  2358 Aug 30 05:58 php-fpm       ->启动脚本
-rw-r--r-- 1 root root 22810 Aug 30 06:01 php-fpm.conf
-rw-r--r-- 1 root root 22810 Aug 30 05:51 php.ini
由于三个文件内容过多,不在粘贴配置文件.将修改好的配置文件传送到master端, 配置文件路径如下:
ll /usr/local/php-fpm/etc/php-fpm.conf.default            ->改名为php-fpm.conf
ll /usr/local/src/php-5.6.25/sapi/fpm/init.d.php-fpm        ->改名为php-fpm
ll /usr/local/php-fpm/etc/php-fpm.conf                   ->改名为php.ini

5. 安装php

[[email protected]_210 php]# cat init.sls
include:
  - php.config
  - php.install
[[email protected]_210 files]# cat /data/etc/salt/top.sls
base:
  '*':
    - php.init
[[email protected]_210 files]# salt 'docker_211' state.highstate test=True       ->测试安装, 无报错即可.
[[email protected]_210 files]# salt 'docker_211' state.highstate
[[email protected]_210 files]# salt 'docker_211' cmd.run 'netstat -anpt|grep "php-fpm"'
docker_211:
    tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      3614/php-fpm


  移步手机端
Linux自动化工具之SaltStack安装PHP FastCGI

1、打开你手机的二维码扫描APP
2、扫描左则的二维码
3、点击扫描获得的网址
4、可以在手机端阅读此文章
标签:

发表评论

选填

必填

必填

选填

请拖动滑块解锁
>>


  用户登录