日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

php header 404 nginx,ThinkPHP在nginx下怎么设置?路由统统404,疯了~

發(fā)布時(shí)間:2025/3/8 php 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php header 404 nginx,ThinkPHP在nginx下怎么设置?路由统统404,疯了~ 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

本地用MAMP跑的代碼,運(yùn)行沒問題。但是部署到CENTOS 6.8 NGINX服務(wù)器上的時(shí)候,路由地址都404了!

[可以訪問] http://something.com/API/public/index.php

[404] http://something.com/API/public/index.php/consult_add

折騰一晚上了。。簡(jiǎn)直了,自打用了LINUX和PHP,90%的時(shí)間都TM在配置環(huán)境。FML

OK,還是耐心點(diǎn)請(qǐng)教下吧。 下面是NGINX的配置文件,怎么修改才能讓TP的路由正常呢?

網(wǎng)站目錄結(jié)構(gòu),API文件夾里是TP

user www www;

worker_processes auto;

error_log /home/wwwlogs/nginx_error.log crit;

pid /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 51200;

events

{

use epoll;

worker_connections 51200;

multi_accept on;

}

http

{

include mime.types;

default_type application/octet-stream;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 50m;

sendfile on;

tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

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 256k;

gzip on;

gzip_min_length 1k;

gzip_buffers 4 16k;

gzip_http_version 1.1;

gzip_comp_level 2;

gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;

gzip_vary on;

gzip_proxied expired no-cache no-store private auth;

gzip_disable "MSIE [1-6]\.";

#limit_conn_zone $binary_remote_addr zone=perip:10m;

##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

server_tokens off;

access_log off;

server

{

listen 80 default_server;

#listen [::]:80 default_server ipv6only=on;

server_name www.mydomain.com;

index index.html index.htm index.php;

root /web;

#error_page 404 /404.html;

include enable-php.conf;

location /nginx_status

{

stub_status on;

access_log off;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 12h;

}

location ~ /\.

{

deny all;

}

location / {

if (!-e $request_filename) {

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

break;

}

}

location /API/ {

if (!-e $request_filename){

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

}

}

access_log /home/wwwlogs/access.log;

}

include vhost/*.conf;

}

這個(gè)配置文件是之前一鍵安裝LNMP時(shí)候生成的,看著有點(diǎn)復(fù)雜,我試著把它替換成下面的簡(jiǎn)單一點(diǎn)的。

server {

listen 80;

server_name something.com;

root /web;

charset utf-8;

location / {

index index.html index.php;

}

location /API/ {

if (!-e $request_filename){

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

}

}

location ~ \.php$ {

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

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

try_files $uri $uri/ /index.php$is_args$args;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

}

}

哎。。。。沒脾氣了

總結(jié)

以上是生活随笔為你收集整理的php header 404 nginx,ThinkPHP在nginx下怎么设置?路由统统404,疯了~的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。