栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP

nginx对php三大框架的配置

PHP 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

nginx对php三大框架的配置

我们在完成一个项目的时候,都会接触到打包上线这样一个过程,本篇文章介绍php三大框架配置。

注:在配置之前确保系统已安装运行环境

Nginx

ThinkPHP5

server {    
    charset utf-8;    
    client_max_body_size 128M;    
    listen 80;    
    server_name www.test.com;	  #指向域名    
    root  /usr/tp5/public;   #指向地址
    index  index.php;    
    
    location ~* .(eot|otf|ttf|woff)$ {    
 add_header Access-Control-Allow-Origin *;    
    }    
    
    location / {    
 index    index.html index.php;    
 if ( -f $request_filename) {    
     break;    
 } 

 if ( !-e $request_filename) {    
     rewrite ^/(.*)$ /index.php/$1 last;    
     break;    
 }    
    }    
    
    location ~ .php {    
 set $script $uri;    
 set $path_info "";    
 if ($uri ~ "^(.+.php)(/.+)") {    
     set $script $1;    
     set $path_info $2;    
 }    
    include   fastcgi_params;    
    fastcgi_index    index.php?IF_REWRITE=1;    
    fastcgi_pass   127.0.0.1:9000;    
    fastcgi_param    PATH_INFO    $path_info;    
    fastcgi_param    script_FILENAME    $document_root$fastcgi_script_name;    
    fastcgi_param    script_NAME    $script;    
    try_files $uri =404;    
    }    
}
Laravel5
server {    
    charset utf-8;    
    client_max_body_size 128M;    
    listen 80;    
    server_name www.test.com;	  #指向域名    
    root  /usr/laravel/public;  #指向地址  
    index  index.php;    
    
    location ~* .(eot|otf|ttf|woff)$ {    
 add_header Access-Control-Allow-Origin *;    
    }    
    
    location / {    
 try_files $uri $uri/ /index.php?$args;    
    }   
     
    location ~ .php$ {    
 include   fastcgi_params;
 fastcgi_index    index.php;
 fastcgi_param    script_FILENAME    $document_root$fastcgi_script_name;    
 fastcgi_pass   127.0.0.1:9000;    
 try_files $uri =404;    
    }    
}

Yii

server {    
    charset utf-8;    
    client_max_body_size 128M;    
    listen 80;    
    server_name www.test.com;	  #指向域名     
    root  /usr/tp5/public;    #指向地址
    index  index.php;    
    
    location ~* .(eot|otf|ttf|woff)$ {    
 add_header Access-Control-Allow-Origin *;    
    }    
    
    location / {    
 try_files $uri $uri/ /index.php?$args;    
    }   
     
    location ~ .php$ {    
 include   fastcgi_params;
 fastcgi_index    index.php;
 fastcgi_param    script_FILENAME    $document_root$fastcgi_script_name;    
 fastcgi_pass   127.0.0.1:9000;    
 try_files $uri =404;    
    }    
}
转载请注明:文章转载自 www.mshxw.com
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号