关于nginx支持thinkphp框架的配置

error_log  logs/error.log  error ;
pid logs/nginx.pid;
user  www;
worker_processes  auto;
worker_rlimit_nofile 51200;


events {
    use epoll;
    worker_connections  51200;
}




http {
    client_body_buffer_size 1024k;
    client_header_buffer_size 2k;
    client_max_body_size 500m;
    default_type application/octet-stream;
    log_not_found off;
    server_tokens off;
    include       mime.types;
    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types       text/plain text/css text/xml text/javascript application/x-javascript application/xml application/rss+xml application/xhtml+xml application/atom_xml;
    gzip_vary on;
    #error_page   500 502 503 504  /50x.html; 
    log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" $http_x_forwarded_for';


    server {
        listen 80 default_server;
        server_name localhost;
        root /home/wwwroot/;
        index index.php index.html index.htm;

     location / {  
        index  index.htm index.html index.php;  
        #如果文件不存在则尝试TP解析  
        try_files  $uri  /index.php$uri;  
    }  
    location ~ .+\.php($|/) {  
       # root        /var/www/html/website;  
        fastcgi_pass   127.0.0.1:9000;  
        fastcgi_index  index.php;  
        fastcgi_buffers 32 8k;          


        #设置PATH_INFO,注意fastcgi_split_path_info已经自动改写了fastcgi_script_name变量,  
        #后面不需要再改写SCRIPT_FILENAME,SCRIPT_NAME环境变量,所以必须在加载fastcgi.conf之前设置  
        fastcgi_split_path_info  ^(.+\.php)(/.*)$;  
        fastcgi_param  PATH_INFO $fastcgi_path_info;  
          
        #加载Nginx默认"服务器环境变量"配置  
        include        fastcgi.conf;  
               }  
    }
    include vhost/*.conf;

}


复制到nginx的配置文件,重启服务,直接就可以使用了(前提:安装完lnmp环境之后没有自定义过nginx文件,自定义过请把自定义的内容加到相应的地方)












评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值