diff --git a/defaults/main.yml b/defaults/main.yml index 892ccdf640b9ab713d33ee691b83cd81be8ea6de..66036679b628ede6ce8720528422bed9a66367d0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,8 @@ php_version: '7.0' php_version_main: '7' +php_fpm_socket: false + php_install_redis: true php_hold_version: false php_repositories: [] diff --git a/tasks/php.yml b/tasks/php.yml index 57de4ca08460cdadea5597720e8779be7c5c416f..21d5c7554b064ac151e489e8b5d8d0a14c930ac2 100644 --- a/tasks/php.yml +++ b/tasks/php.yml @@ -127,6 +127,25 @@ group=root mode='644' +- block: + + - name: "PHP | Apache FPM Socket Configuration" + template: + src='etc-apache2-conf-available-php-fpm' + dest='/etc/apache2/{{ apache_conf_dir }}/php{{ php_version_main }}-fpm.conf' + owner='root' + group='root' + mode='644' + notify: + - "Apache | Restart Apache" + + - name: "PHP | Enable Apache PHP FPM Configuration" + command: a2enconf php{{ php_version_main }}-fpm creates=/etc/apache2/conf-enabled/php{{ php_version_main }}-fpm{{ apache_conf_ext }} + notify: + - "Apache | Restart Apache" + + when: php_fpm_socket + - name: "PHP | FPM Default Pool Configuration" template: src=php_pool.conf diff --git a/templates/etc-apache2-conf-available-php-fpm b/templates/etc-apache2-conf-available-php-fpm new file mode 100644 index 0000000000000000000000000000000000000000..495e4c2c6611a4e89e06cbfc2805c2a2175e07d5 --- /dev/null +++ b/templates/etc-apache2-conf-available-php-fpm @@ -0,0 +1,10 @@ +<IfModule mod_fastcgi.c> + AddHandler php{{ php_version_main }}-fcgi .php + Action php{{ php_version_main }}-fcgi /php{{ php_version_main }}-fcgi + Alias /php{{ php_version_main }}-fcgi /usr/lib/cgi-bin/php{{ php_version_main }}-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php{{ php_version_main }}-fcgi -socket /var/run/php{{ php_version_main }}-fpm.sock -pass-header Authorization + + <Directory /usr/lib/cgi-bin> + Include /etc/apache2/{{ apache_conf_dir }}/global-deny.conf + </Directory> +</IfModule> diff --git a/templates/php_pool.conf b/templates/php_pool.conf index 6bf067496c9b8ef159bfcc44247b03265ba843ec..36563fa55c9111aaa796b8f8bc849922f7c4de63 100644 --- a/templates/php_pool.conf +++ b/templates/php_pool.conf @@ -3,7 +3,11 @@ user = www-data group = www-data ;chroot = /var/www{{apache_server_default_root|default('')}} chdir = / +{% if php_fpm_socket %} +listen = /var/run/php{{ php_version_main }}-fpm.sock +{% else %} listen = 127.0.0.1:9000 +{% endif %} ; Process manager pm = dynamic