apache和nginx比起来,我更倾向nginx,占用资源少,且性能高,不管是开发还是生产环境都很好用。那么,如何配置nginx让其支持yii2.0的访问呢?
配置范例如下:
server {
listen 80;
server_name reson.com;
location / {
root D:/wwwroot/reson/web;
index index.html index.php;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
location ~ \.php$ {
root D:/wwwroot/reson/web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}