diff --git a/README.md b/README.md index 5afb9aa..c0ba0df 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ FreeBSD: - `nginx_resolver`: list of DNS resolver (default: OpenDNS) - `nginx_error_log_level`: default log level - `nginx_auto_config_httpv2`: boolean, auto configure HTTP2 where possible +- `nginx_fastcgi_fix_realpath`: boolean, use realpath for fastcgi (fix problems with symlinks and PHP opcache) ### Nginx Configuration diff --git a/defaults/main.yml b/defaults/main.yml index bece1dd..bdd1aa1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,6 +18,7 @@ nginx_error_log_level: 'warn' # http://nginx.org/en/docs/ngx_core_module.html#er nginx_auto_config_httpv2: true nginx_default_vhost: null nginx_default_vhost_ssl: null +nginx_fastcgi_fix_realpath: true # # Nginx directories diff --git a/tasks/config.yml b/tasks/config.yml index 7aea924..34f5b51 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -19,3 +19,16 @@ dest="{{ nginx_etc_dir }}/conf.d/custom.conf" notify: reload nginx +- name: LINEINFILE | Fix path + lineinfile: > + regexp='{{ item.0.regexp }}' + line='{{ item.0.line }}' + dest='{{ item.1 }}' + with_nested: + - + - regexp: '^fastcgi_param SCRIPT_FILENAME' + line: 'fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;' + - regexp: '^fastcgi_param DOCUMENT_ROOT' + line: 'fastcgi_param DOCUMENT_ROOT $realpath_root;' + - [ '/etc/nginx/fastcgi_params', '/etc/nginx/fastcgi.conf' ] + when: nginx_fastcgi_fix_realpath