为了学习,我尝试使用puppet on vagrant提供一个php web服务器。但是,我将在浏览器窗口中获得php代码转储,而不是执行。我试着寻找解决问题的办法,但在这里找不到。任何帮助都将不胜感激。
这就是我到目前为止所做的。
木偶大师/清单/网站.pp

node /^puppet/ {
  include puppetmaster
}

node /^web/ {
  include webserver
  include php
}

puppetmaster/module/webserver/manifests/init.pp(自定义模块)
class webserver {
  notify{"provision a web server": }

  package{['git', 'links']:
    ensure => installed,
  }

  include apache

  file{'/var/www/test':
    ensure => directory,
    owner  => 'www-data',
    group  => 'www-data',
  }

  vcsrepo { "/var/www/test":
    ensure   => present,
    provider => git,
    source   => 'https://github.com/example/test.git',
    require => File['/var/www/test'],
  }

  apache::vhost{'git.example.com':
    port    => '80',
    docroot => '/var/www/test',
    require => File['/var/www/test'],
  }

  host{'git.example.com':
    ip => '127.0.0.1',
  }
}

漫游文件
VAGRANTFILE_API_VERSION = "2"

# Assinging static IP
$puppet_ip = "10.1.1.33"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.box = "puppetlabs/ubuntu-14.04-32-puppet"
config.vm.network "private_network", ip: "10.1.1.34"

    config.vm.define "web01" do |web|
        web.vm.hostname = "web01"
        web.vm.network :forwarded_port, host: 1234, guest: 8983
        web.vm.network :forwarded_port, host: 11000, guest: 80
        web.vm.provision "shell", inline: "apt-get update"
        web.vm.provision "shell", inline: "echo '#{$puppet_ip} puppet' >> /etc/hosts"
    end
end

apache2.conf(web01.home)
# Security
ServerTokens OS
ServerSignature On
TraceEnable On

ServerName "web01.home"
ServerRoot "/etc/apache2"
PidFile ${APACHE_PID_FILE}
Timeout 120
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15

User www-data
Group www-data

AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

<Directory />
  Options FollowSymLinks
  AllowOverride None
</Directory>


HostnameLookups Off
ErrorLog "/var/log/apache2/error.log"
LogLevel warn
EnableSendfile On

#Listen 80


Include "/etc/apache2/mods-enabled/*.load"
Include "/etc/apache2/mods-enabled/*.conf"
Include "/etc/apache2/ports.conf"

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

IncludeOptional "/etc/apache2/conf.d/*.conf"
IncludeOptional "/etc/apache2/sites-enabled/*"

非常感谢

最佳答案

为了解决您的问题,您可以创建一个简单的

LoadModule php5_module modules/libphp5.so
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

并要求puppet在php.conf中推送此文件,以便至少运行php脚本
第二个最佳选择是查看https://puphpet.com以便完成所有的资源调配

10-04 16:01