一、nginx配置
1、nginx简单配置
其实和部署其他php项目的配置并没有明显的区别,只不过为了url更加友好,一般需要隐藏index.php,个人推荐使用try_files
location / {
root /webroot/www;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php;
}
注:
$uri是nginx的内置变量,表示当前请求uri
try_files表示依次匹配url的规则,上面的例子表示如果$uri不存在,则匹配$uri/,如果$uri/也不存在,则把请求转向到/index.php
2、nginx完整配置
假如域名是www.shixinke.com
项目目录:/webroot/www/mtest
项目目录结构如下:
配置如下:
server {
listen 80;
server_name www.shixinke.com;
access_log logs/www.shixinke.com.access.log main;
error_log logs/www.shixinke.com.error.log;
location / {
root /webroot/www/mtest/public;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /webroot/www/mtest/public;
}
location ~ \.php {
root /webroot/www/mtest/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
二、PHP配置
1、前提是已经安装Yaf扩展,并启用yaf扩展,即在php.ini中打开yaf
extension=yaf.so
2、对于yaf的一些配置
下面的配置是针对生产环境的:如果不开启命名空间的话,则应该注释掉第二行
yaf.environ=product
yaf.use_namespace=1
yaf.cache_config=1