为了学习,我试图在Vagrant上使用Puppet来配置PHP Web服务器。但是,我在浏览器窗口中获取PHP代码转储,而不是执行。我一直试图寻找问题的解决方案,但我在这里找不到一个。任何帮助都将受到高度赞赏。
这是我到目前为止所做的。
戏梦人生/表现/ site.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
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/*"
感谢adavnce
答案 0 :(得分:2)
要解决您的问题,您可以使用有限的
创建一个简单的php.conf
LoadModule php5_module modules/libphp5.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
并要求puppet在/etc/apache2/conf.d/
中推送此文件,以便至少运行php脚本
第二个最佳选择是查看https://puphpet.com,以便为您完成所有配置