搜索
系统检测到您的用户名不符合规范:

Nginx1.12为什么不能解析ThinkPHP3.2的项目?该怎样配置才是正确的?

浏览:2904 发布日期:2017年04月17日 分类:求助交流 关键字: Nginx TP3.2 PATHINFO LNMP
我的环境是CentOS7.3 64位 Nginx1.12.0 MySQL5.7.18 PHP7.1.4 全部都是编译安装的,单独放一个php文件能正常解析出来,但是将ThinkPHP3.2的项目放上去就不解析,直接404报错,配置文件我也根据ThinkPHP的手册更改了,但是不起作用,也尝试更换URL模式,4种模式都尝试过,都不起作用,首页都进不去。网上的答案基本也是大同小异,而且他们的情况是首页能进去,其他页面进不去,我的情况是,首页都进不去。我的Nginx是最新版的请问该怎样配置,才能让我的ThinkPHP项目正常的访问?我现在的配置如下:######
### 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;
}
}
}
最佳答案
评论() 相关
收藏
Somosaguas
积分:25 等级:LV0
热点推荐
(追記) (追記ここまで)
最新更新

我们

合作

网站

信息

ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。

AltStyle によって変換されたページ (->オリジナル) /