【发布时间】:2014-02-24 03:41:10
【问题描述】:
我使用 PHP 5.4 和 Nginx 通过预配置的 https://puphpet.com/ 包设置我的 vagrant box。
配置后,我总是必须自己更改 vhost_autogen.conf - 我想这不是 vagrant 和 puppet 背后的想法 :-) 我该怎么做:
- 自动删除 vhost_autogen.conf 并用另一个替换它
或
- 将以下设置添加为 puppet 配置?
这是所需的虚拟主机设置:
服务器{
听 *:80;
server_name example.dev www.example.dev;
root /var/www/example.com;
索引 index.php;
access_log /var/log/nginx/example.com.de.access.log;
error_log /var/log/nginx/example.com.error.log;
if ($host ~* www.(.*)) { 设置 $host_without_www $1; 重写 ^(.*)$ $scheme://$host_without_www$1 永久; #1 #rewrite ^ $scheme://$host_without_www$1request_uri 永久; #2 }
# 重写为缩小 重写 ^/min/([a-z]=.*) /min/index.php?$1 last;
#规范化codeigniter url端点
if ($request_uri ~* ^(/start(/index)?|/index(.php)?)/?$) { 重写 ^(.*)$ / 永久; }
# 从所有控制器中删除尾随“索引” if ($request_uri ~* index/?$) { 重写 ^/(.*)/index/?$ /$1 永久; }
# 删除尾部斜杠(防止 SEO 重复内容问题) if (!-d $request_filename) { 重写 ^/(.+)/$ /$1 永久; }
# 删除对“system”文件夹的访问,也允许“System.php”控制器 if ($request_uri ~* ^/system) { 最后重写 ^/(.*)$ /index.php?/$1; 休息; }
# 除非请求是针对有效文件(图像、js、css 等),否则发送到引导程序 if (!-e $request_filename) { 最后重写 ^/(.*)$ /index.php?/$1; 休息; }
# 全部捕获 error_page 404 /index.php;
位置/{ 根 /var/www/example.com; 最后重写 ^/min/([a-z]=.*) /min/index.php?$1; }
location = /robots.txt { access_log off; log_not_found 关闭; } 位置 = /favicon.ico { access_log off; log_not_found 关闭; } 位置~/。 { access_log off; log_not_found 关闭;全部否认; } 位置 ~ ~$ { access_log off; log_not_found 关闭;全部否认; }
位置 ~ .php$ { 根 /var/www/example.com; try_files $uri $uri/ /index.php?$args ; 索引 index.html index.htm index.php; fastcgi_index index.php; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param APP_ENV dev;
fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params;} }
【问题讨论】: