nginx1.12 php,Nginx1.12能够正常解析php文件,但是为什么不能解析ThinkPHP3.2的项目?该怎样配置才是正确的?...

######

###  Description: The config file of Nginx, no-www redircting, gzip functions

###  Author:  licong  2017.04.14  https://www.lcgod.com/

######

user  nginx nginx;

worker_processes  1;

error_log  /var/log/nginx/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

pid        /var/run/nginx/nginx.pid;

events {

use epoll;

worker_connections  1024;

}

http {

include       mime.types;

default_type  application/octet-stream;

charset UTF-8;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;

#tcp_nopush     on;

#keepalive_timeout  0;

keepalive_timeout  65;

#隐藏Nginx版本信息,禁止网站目录浏览

server_tokens off;

autoindex off;

#当FastCGI后端服务器处理请求给出http响应码为4xx和5xx时,就转发给nginx

fastcgi_intercept_errors on;

#关于fastcgi的配置

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffer_size 64k;

fastcgi_buffers 4 64k;

fastcgi_busy_buffers_size 128k;

fastcgi_temp_file_write_size 128k;

#支持gzip压缩

gzip on;

gzip_min_length 1k;

gzip_buffers 16 64k;

gzip_http_version 1.1;

gzip_comp_level 6;

gzip_types text/plain application/x-javascript text/css application/javascript text/javascript image/jpeg image/gif image/png application/xml application/json;

gzip_vary on;

gzip_disable "MSIE [1-6].(?!.*SV1)";

#

server {

listen               *:80;

server_name          www.lcgod.com;

#301重定向

if ($host != 'www.lcgod.com' ) {

rewrite ^(.*)/$ http://www.lcgod.com/$1 permanent;

}

# 不产生日志

access_log off;

location ~* ^/(favicon.ico|robots.txt)$ {

root html;

expires max;

log_not_found off;

break;

}

#设置网站根目录

root   /home/www;

index  index.php index.html;

#access_log  /var/log/nginx/log/host.access.log  main;

#设置css/javascript/图片等静态资源的缓存时间

location ~ .*\.(css|js|ico|png|gif|jpg|json|mp3|mp4|flv|swf)(.*) {

expires 60d;

}

# include /etc/nginx/default.d/*.conf;

# 设置网站的config文件不被访问,保证安全

location = /config.inc.php{

deny  all;

}

#URLRewrite

location / {

if (!-e $request_filename) {

rewrite  ^(.*)$  /index.php/s=$1 last;

break;

}

}

#设置访问favicon.ico时不产生日志

location = /favicon.ico {

access_log off;

}

#设置40系列错误的应答文件为40x.html

error_page  400 401 402 403 404  /40x.html;

location = /40x.html {

root   html/404;

index  index.html index.htm;

}

#设置50系列错误的应答文件为50x.html

#

error_page   500 501 502 503 504  /50x.html;

location = /50x.html {

root   html/502;

index  index.html index.htm;

}

## 设置Nginx和php通信机制为tcp的socket模式,而不是直接监听9000端口

location ~ .*\.php(\/.*)*$ {

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  /home/www/$fastcgi_script_name;

include        fastcgi_params;

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值