4
爲了學習,我試圖使用Pagpet on Vagrant配置PHP Web服務器。但是,我正在瀏覽器窗口上獲取PHP代碼轉儲,而不是執行。我試圖尋找解決問題的辦法,但我在這裏找不到。任何幫助將不勝感激。木偶:如何停止在瀏覽器窗口中打印PHP代碼
這是我迄今爲止所做的。
戲夢人生/艙單/ site.pp
node /^puppet/ {
include puppetmaster
}
node /^web/ {
include webserver
include php
}
戲夢人生/模塊/網絡服務器/艙單/ 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
您是否安裝了php模塊,您的httpd.conf在配置之後如何? –
是的,我已經通過執行「puppet module install example42-php」安裝了PHP模塊,並且我還編輯了原始文章以包含apache2.conf文件。 – getmizanur
謝謝,所以安裝了php,但apache並不知道它,添加一個答案,以便您可以添加Apache的必要conf –