网站首页 > 技术教程 正文
网络上很多关于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;
}
}
猜你喜欢
- 2024-10-15 架构师之必杀技——反向代理&负载均衡器
- 2024-10-15 面试腾讯、字节等大厂后,我总结一份面试文档给大家参考
- 2024-10-15 swoole运行模式加速laravel应用的详细介绍
- 2024-10-15 (PHP)开发Laravel扩展的基本流程(laravel php artisan)
- 2024-10-15 「PHP 技巧」 不要直接克隆对象,请使用深拷贝
- 2024-10-15 Yii2负载均衡必备:MD4文件缓存技巧
- 2024-10-05 网站跨域的五种解决方式(浏览器解决跨域)
- 2024-10-05 用户登录实现(登录功能实现)
- 2024-10-05 使用kubeadm部署Kubernetes 1.22(kubeedge部署)
- 2024-10-05 PHP性能全面优化-值得收藏(php性能调优工具)
你 发表评论:
欢迎- 08-06linux 和 windows文件格式互相转换
- 08-06谷歌 ChromeOS 已支持 7z、iso、tar 文件格式
- 08-06Linux下比较文件内容的6种方法
- 08-06文件格式及功能汇总
- 08-0610个Linux文件内容查看命令的实用示例
- 08-06Linux-如何区分不同文件类型
- 08-06Zabbix技术分享——监控windows进程资源使用情况
- 08-06Linux系统卡顿?学会ps命令这三招,轻松定位问题进程
- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)