[英]How to connect Nginx and PHP via Puppet (on Vagrant)?
I'm setting up a puppet file for Vagrant to use to provision a LEMP stack and so far, I've been able to install everything I need via this: 我正在为Vagrant设置一个人偶文件以用于配置LEMP堆栈,到目前为止,我已经能够通过以下方式安装所需的一切:
exec { "apt-get update":
command => "/usr/bin/apt-get update",
}
package { "acl":
ensure => "present",
require => Exec ["apt-get update"],
}
class nginx{
package { "nginx":
ensure => present,
require => Exec ["apt-get update"],
}
service { "nginx":
ensure => "running",
require => Package["nginx"],
}
file { "/var/www":
ensure => "link",
target => "/vagrant/web",
require => Package["nginx"],
notify => Service["nginx"],
force => true,
}
}
class php {
package { "php5-cli": ensure => present }
package { "php5-dev": ensure => present }
package { "php5-mysql": ensure => present }
package { "php-pear": ensure => present }
package { "php5-common": ensure => present}
package { "php5-fpm": ensure => present}
package { "php5-cgi": ensure => present}
package { "php-apc": ensure => present}
exec { "pear upgrade":
command => "/usr/bin/pear upgrade",
require => Package["php-pear"],
}
}
class mysql {
package { "mysql-server":
require => Exec["apt-get update"],
ensure => present,
}
service { "mysql":
enable => true,
ensure => running,
require => Package["mysql-server"],
}
exec { "Set MySQL server root password":
require => Package["mysql-server"],
unless => "/usr/bin/mysqladmin -uroot -proot status",
command => "/usr/bin/mysqladmin -uroot password root",
}
}
include nginx
include php
include mysql
I've Vagrant setup correctly, I was using a LAMP stack script for that and it worked flawlessly; 我已经正确设置了Vagrant,使用了LAMP堆栈脚本,它可以完美地工作。 however, substituting Nginx for Apache and php-fpm for php5 caused a break. 但是,用Nginx代替Apache和用php-fpm代替php5导致了问题。 Whenever I try to load up my site, I get a "Welcome to nginx!". 每当我尝试加载我的网站时,都会收到“欢迎使用nginx!”。 If I specify a specific path to an image (or any other static file), the image loads up. 如果我指定图像(或任何其他静态文件)的特定路径,则会加载图像。 If I specify a specific path to a PHP file, the PHP file gets downloaded instead of executing. 如果我指定PHP文件的特定路径,则会下载PHP文件而不是执行该文件。
I'm using Ubuntu 12.04 64-bit. 我正在使用Ubuntu 12.04 64位。
I'm thinking that the socket is not correctly setup from the Nginx side but I'm not entirely sure how I can set it up via a puppet manifests file for portability. 我在想从Nginx端未正确设置套接字,但我不完全确定如何通过木偶清单文件进行设置以实现可移植性。
Ideas? 想法?
You need puppet to replace the /etc/nginx/sites-available/default
file with a config that has the php socket stuff uncommented. 您需要使用将php套接字内容未注释的配置替换为/etc/nginx/sites-available/default
文件的p。
Try uncommenting the location ~ \\.php$
block and restart nginx to see if things work... if so then getting puppet to replace that file with your config should get it working for you. 尝试取消注释该location ~ \\.php$
块,然后重新启动nginx以查看一切是否正常……如果是这样,那么让p将其替换为您的配置即可使其工作。
There are quite a few more robust nginx puppet scripts out there that you might want to take a look at as well... you should probably being doing this as a vhost for example... and beware that there are some security issues to look out for if using this in production. 还有很多健壮的Nginx木偶脚本 ,您可能还想看一看...例如,您可能应该以虚拟主机的身份进行此操作...并且要注意,有一些安全问题需要考虑如果在生产中使用此功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.