网络上很多关于PHP的MVC环境nginx配置,但是运行后问题很多,或者根本就不行,预计这些内容都是四处复制或者采集的,也不验证。下面分享一个真正能用的MVC配置。
PHP+NGINX+LINUX或者WINDOW
请把配置放在nginx的conf目录下,并加载到http{}配置中。
配置是WINDOW或者LINUX通用的,只要要把ROOT改一下就可:
#root /var/web/website_dirname; #这是LINUX适用
root M:/web/website_dirname; #这是WINDOW适用
下面是server配置:
server {
listen 80;
server_name www.youweb.com;
#charset koi8-r;
#access_log logs/host.access.log main;
#root /var/web/website_dirname; #这是LINUX适用
root M:/web/website_dirname; #这是WINDOW适用
index index.html index.htm index.php;
location ~ \.(css|js|jpg|jpeg|png|bmp|gif|svg|ttf|woff|woff2|eot|otf|ico|css\.map|min\.map)(.*)$ {
break;
}
location / {
#index index.htm index.html index.php;
#访问路径的文件不存在则重写URL转交给PHP框架解决
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ \.php/?.*$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#加载Nginx默认"服务器环境变量"配置
include fastcgi.conf;
#include fastcgi_params;
#设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量
set $fastcgi_script_name2 $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
set $fastcgi_script_name2 $1;
set $path_info $2;
}
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
房地产公司企业织梦dedecms模板
9.7.0 砍价宝小程序商城系统带抢购拼团砍价助力核销系统源码
PHPEMS在线模拟考试系统在线课程教学系统php程序开源源码
儿童医疗防护口罩生产公司网站织梦模板(带手机端)
小说网站后端一件自动采集支持txt下载
响应式手机个人博客文章资讯新闻帝国CMS网站模板整站自适应HTML5
discuz模板教育课程职业培训4学习教程论坛网站模版dz模板
最新PHP宽屏大型餐饮加盟代理商网站+PC端+手机WAP+微信+繁简+中英文双语多合一建站源码
营销型体育培训班体育器材类网站织梦模板(带移动端)
【企业网站+自适应】html5酒产品企业源码 烟酒网站源码 长页面模板