简体   繁体   English

如何使用SaltStack启用php扩展

[英]How to enable php extension using SaltStack

I'm using SaltStack to provision my Vagrant VM. 我正在使用SaltStack来配置我的Vagrant VM。 I've installed php fine, but I need to enable the intl extension. 我已经安装了php,但是我需要启用intl扩展。 I'm pretty sure that it is installed but I can't work out how I can get salt to enable it for me. 我很确定已经安装了它,但是我无法弄清楚如何为我启用它。 Is there a way I can get it to create a php.ini or something like that? 有没有办法让我创建一个php.ini或类似的东西?

Here's my php55.sls file: 这是我的php55.sls文件:

php55:
    pkg:
        - installed
        - pkgs:
            - php55
            - php55-apcu
            - php55-mod-php
            - libjpeg-turbo8

and my top.sls: 和我的top.sls:

base:
  '*':
    - apache2-mpm-prefork
    - php55
    - mysql

Here is an example of how I install a module using PECL and enable it. 这是我如何使用PECL安装模块并启用它的示例。 The last state is what you want, but I paste the full example to clarify. 最后一个状态就是您想要的状态,但是我粘贴了完整的示例进行说明。

php-mongo-builddeps:
  pkg.installed:
    - pkgs:
      - php-devel
      - glibc-devel
      - gcc
      - php-phpunit-PHPUnit
      - php-bcmath

mongo-php-reqs:
  pecl.installed:
    - name: mongo
    - require:
      - pkg: php-pkgs
      - pkg: php-mongo-builddeps

php-enable-extension:
  file.managed:
    - name: /etc/php.d/mongo.ini
    - user: root
    - group: root
    - mode: 644
    - contents: 'extension=mongo.so'
    - watch_in:
      - service: httpd

I was googling for a better solution, when i stumbled upon your question. 当我偶然发现您的问题时,我一直在寻找更好的解决方案。 I don't think it's perfect, but i prefer enabling it per cli vs managing a file, like diegows suggests. 我不认为它是完美的,但我喜欢按cli启用它,而不是像管理人员建议的那样管理文件。

php7.0:
  pkg.installed:
    - pkgs:
      - php7.0-cli

install xdebug:
  pecl.installed:
    - name: xdebug
    - require:
      - pkg: php7.0
  cmd.run:
    - name: phpenmod xdebug
    - require:
      - pecl: install xdebug

ps. PS。 for php 5.x, use php5enmod , instead of phpenmod 对于php 5.x,请使用php5enmod ,而不是phpenmod

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM