diff --git a/php/ng/apache2/files/mod_php.conf.jinja b/php/ng/apache2/files/mod_php.conf.jinja new file mode 100644 index 0000000..9c70790 --- /dev/null +++ b/php/ng/apache2/files/mod_php.conf.jinja @@ -0,0 +1,14 @@ +{% from "php/ng/map.jinja" import php with context %} +{% from "php/ng/map.jinja" import phpng_version with context %} +{% set major = phpng_version.split('.')|first %} + +LoadModule php{{ major }}_module /usr/local/libexec/{{ php.lookup.apache2.name }}/libphp{{ major }}.so + +DirectoryIndex index.html index.php + + + SetHandler application/x-httpd-php + + + SetHandler application/x-httpd-php-source + diff --git a/php/ng/apache2/ini.sls b/php/ng/apache2/ini.sls index 00c5e22..8f01a8a 100644 --- a/php/ng/apache2/ini.sls +++ b/php/ng/apache2/ini.sls @@ -1,4 +1,4 @@ -# Manages the libapache2-mod-php5 main ini file +# Manages the main Apache2 ini file {% from "php/ng/map.jinja" import php with context %} {% from "php/ng/ini.jinja" import php_ini %} diff --git a/php/ng/apache2/init.sls b/php/ng/apache2/init.sls index 424da3d..2ebfb1e 100644 --- a/php/ng/apache2/init.sls +++ b/php/ng/apache2/init.sls @@ -1,8 +1,8 @@ -# Installs libapache2-mod-php5 package and manages the associated php.ini on os Debian -{% if grains['os_family'] == "Debian" %} - include: +{% if grains['os_family'] in ["Debian", "FreeBSD"] %} - php.ng.apache2.install +{% endif %} #END: os = Debian|FreeBSD +{% if grains['os_family'] == "Debian" %} - php.ng.apache2.ini extend: @@ -10,5 +10,4 @@ extend: file: - require: - sls: php.ng.apache2.install - {% endif %} #END: os = debian diff --git a/php/ng/apache2/install.sls b/php/ng/apache2/install.sls index 0f1ed17..46c7da4 100644 --- a/php/ng/apache2/install.sls +++ b/php/ng/apache2/install.sls @@ -1,2 +1,18 @@ +{% from "php/ng/map.jinja" import php with context %} + {% set state = 'apache2' %} {% include "php/ng/installed.jinja" %} + +{% if grains['os_family'] == "FreeBSD" %} +{{ php.lookup.apache2.module_config }}: + file.managed: + - source: salt://php/ng/apache2/files/mod_php.conf.jinja + - template: jinja +{% if salt['pillar.get']('php:ng:use_apache_formula', True) %} + - makedirs: true + - require_in: + - sls: apache + - watch_in: + - module: apache-restart +{% endif %} #END: use apache formula +{% endif %} #END: os = debian diff --git a/php/ng/map.jinja b/php/ng/map.jinja index da8b1b1..d4d768e 100644 --- a/php/ng/map.jinja +++ b/php/ng/map.jinja @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- # vim: ft=jinja +{%- set phpng_version = salt['pillar.get']('php:ng:version', '7.0')|string %} +{%- set freebsd_phpng_version = phpng_version.replace('.', '') %} + {%- if salt['grains.get']('os') == "Ubuntu" %} {%- set use_external_repo = salt['pillar.get']('php:use_external_repo', False) %} {%- if use_external_repo %} - {%- set phpng_version = salt['pillar.get']('php:ng:version', '7.0')|string %} {%- if salt['grains.get']('osrelease')|string >= '16.04' %} {%- set php = salt['pillar.get']('php:ng', { 'lookup': salt['grains.filter_by']({ @@ -1767,7 +1769,6 @@ {%- endif %} {%- endif %} {%- elif salt['grains.get']('os') == "Debian" %} - {%- set phpng_version = salt['pillar.get']('php:ng:version', '7.0')|string %} {%- if phpng_version|string == '5' %} {%- set confdir = '/etc/php5' %} {%- else %} @@ -2386,6 +2387,15 @@ 'ini': '/etc/php/conf.d/xcache.ini', }, }, + 'FreeBSD': { + 'apache2': { + 'module_config': '/usr/local/etc/apache24/modules.d/050_mod_php.conf', + 'name': 'apache24', + }, + 'pkgs': { + 'apache2': 'mod_php' + freebsd_phpng_version, + }, + }, }), 'fpm': { 'service': { diff --git a/pillar.example b/pillar.example index a2699e9..abea95d 100644 --- a/pillar.example +++ b/pillar.example @@ -171,3 +171,7 @@ php: - pcntl_wait 'CLI Server': cli_server_color: 'On' + + # When using php.ng.apache2 on FreeBSD: + # Set this to False if you're not using apache-formula + use_apache_formula: True