我创建了一个自定义资源来添加具有直接php支持的vhost。 创建了vhost并添加了自定义位置但是如果我尝试它会下载所有文件而不是处理它们。
我缺少什么? https://github.com/jfryman/puppet-nginx/是我使用的模块。
pp文件:
$full_web_path = '/var/www'
define web::nginx_php_vhost (
$backend_port = 9000,
$php = true,
$proxy = undef,
$www_root = "${full_web_path}/${name}/",
$location_cfg_append = undef,
) {
nginx::resource::vhost { "${name}.${::domain} ${name}":
ensure => present,
listen_port => 80,
www_root => $www_root,
owner => 'evancauwenberg',
group => 'www-data',
mode => '0755',
access_log => "/var/log/nginx/${name}_access.log",
error_log => "/var/log/nginx/${name}_error.log",
location_cfg_append => {
try_files => '$uri $uri/ =404'
},
index_files => [ 'index.php' ],
}
if $php {
nginx::resource::location { "${name}_root":
ensure => present,
vhost => "${name}.${::domain} ${name}",
www_root => $www_root,
location => '~ \.php$',
index_files => ['index.php', 'index.html', 'index.htm'],
proxy => undef,
fastcgi => "127.0.0.1:${backend_port}",
fastcgi_script => undef,
location_cfg_append => {
fastcgi_split_path_info => '^(.+\.php)(/.+)$',
fastcgi_index => 'index.php',
fastcgi_connect_timeout => '3m',
fastcgi_read_timeout => '3m',
fastcgi_send_timeout => '3m'
}
}
}
}
web::nginx_php_vhost { "evert.be":
www_root => "/var/www/evert.be",
}
创建的vhost:
server {
listen *:80;
server_name evert.be;
index index.php;
access_log /var/log/nginx/evert_access.log;
error_log /var/log/nginx/evert_error.log;
location ~ \.php$ {
root /var/www/evert/evert.be;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_connect_timeout 3m;
fastcgi_index index.php;
fastcgi_read_timeout 3m;
fastcgi_send_timeout 3m;
fastcgi_split_path_info ^(.+\.php)(/.+)$;;
}
location / {
root /var/www/evert/evert.be;
try_files $uri $uri/ =404;
}
}