为了账号安全,请及时绑定邮箱和手机立即绑定

nginx对php三大框架的配置

标签:
PHP

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

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

Nginx

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;    
    }    
}
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;    
    }    
}
点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消