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

php文件存在 访问ip nginx显示404找不到 静态html文件可以访问

php文件存在 访问ip nginx显示404找不到 静态html文件可以访问

慕丝7291255 2019-05-21 11:28:00
服务器文件夹下php文件存在访问ipnginx却显示404找不到静态html文件可以访问。谷歌百度修改了php-fpm和文件夹权限还是不对。我在本地虚拟机下搭建同样配置就没有问题。开启了错误日志里面也没有记录。跪求大神指点一下配置:userwwwwww;worker_processesauto;error_log/home/wwwlogs/nginx_error.logcrit;pid/usr/local/nginx/logs/nginx.pid;Specifiesthevalueformaximumfiledescriptorsthatcanbeopenedbythisprocess.worker_rlimit_nofile51200;events{useepoll;worker_connections51200;multi_accepton;}http{includemime.types;default_typeapplication/octet-stream;server_names_hash_bucket_size128;client_header_buffer_size32k;large_client_header_buffers432k;client_max_body_size50m;sendfileon;tcp_nopushon;keepalive_timeout60;tcp_nodelayon;fastcgi_connect_timeout300;fastcgi_send_timeout300;fastcgi_read_timeout300;fastcgi_buffer_size64k;fastcgi_buffers464k;fastcgi_busy_buffers_size128k;fastcgi_temp_file_write_size256k;gzipon;gzip_min_length1k;gzip_buffers416k;gzip_http_version1.1;gzip_comp_level2;gzip_typestext/plainapplication/javascriptapplication/x-javascripttext/javascripttext/cssapplication/xmlapplication/xml+rss;gzip_varyon;gzip_proxiedexpiredno-cacheno-storeprivateauth;gzip_disable"MSIE[1-6]\.";#limit_conn_zone$binary_remote_addrzone=perip:10m;##Ifenablelimit_conn_zone,add"limit_connperip10;"toserversection.server_tokensoff;access_logoff;server{listen80default_server;#listen[::]:80default_serveripv6only=on;server_name_;root/home/wwwroot/ssrpanel/public;#indexindex.php;indexindex.htmlindex.htmindex.php;#error_page404/404.html;#DenyaccesstoPHPfilesinspecificdirectory#location~/(wp-content|uploads|wp-includes|images)/.*\.php${denyall;}includeenable-php.conf;location/{try_files$uri$uri//index.php$is_args$args;}location/nginx_status{stub_statuson;access_logoff;}location~.*\.(gif|jpg|jpeg|png|bmp|swf)${expires30d;}location~.*\.(js|css)?${expires12h;}location~/.well-known{allowall;}location~/\.{denyall;}access_log/home/wwwlogs/access.log;}includevhost/*.conf;}enanle-php.conf配置:location~[^/]\.php(/|$){try_files$uri=404;fastcgi_passunix:/tmp/php-cgi.sock;fastcgi_indexindex.php;includefastcgi.conf;}fast.cgifastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;fastcgi_paramQUERY_STRING$query_string;fastcgi_paramREQUEST_METHOD$request_method;fastcgi_paramCONTENT_TYPE$content_type;fastcgi_paramCONTENT_LENGTH$content_length;fastcgi_paramSCRIPT_NAME$fastcgi_script_name;fastcgi_paramREQUEST_URI$request_uri;fastcgi_paramDOCUMENT_URI$document_uri;fastcgi_paramDOCUMENT_ROOT$document_root;fastcgi_paramSERVER_PROTOCOL$server_protocol;fastcgi_paramREQUEST_SCHEME$scheme;fastcgi_paramHTTPS$httpsif_not_empty;fastcgi_paramGATEWAY_INTERFACECGI/1.1;fastcgi_paramSERVER_SOFTWAREnginx/$nginx_version;fastcgi_paramREMOTE_ADDR$remote_addr;fastcgi_paramREMOTE_PORT$remote_port;fastcgi_paramSERVER_ADDR$server_addr;fastcgi_paramSERVER_PORT$server_port;fastcgi_paramSERVER_NAME$server_name;#PHPonly,requiredifPHPwasbuiltwith--enable-force-cgi-redirectfastcgi_paramREDIRECT_STATUS200;#fastcgi_paramPHP_ADMIN_VALUE"open_basedir=$document_root/:/tmp/:/proc/";
查看完整描述

2 回答

?
慕虎7371278

TA贡献1802条经验 获得超4个赞

配置里的php的include太多级了,感觉是fastcgi这里出的问题……
我给个标准版吧,替换下enable-php.conf里的内容,重启下看有没有效果:
location~\.php${
try_files$uri=404;
#fastcgi
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_indexindex.php;
fastcgi_split_path_info^(.+\.php)(/.+)$;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
fastcgi_intercept_errorsoff;
fastcgi_buffer_size128k;
fastcgi_buffers25616k;
fastcgi_busy_buffers_size256k;
fastcgi_temp_file_write_size256k;
#defaultfastcgi_params
includefastcgi_params;
}
                            
查看完整回答
反对 回复 2019-05-21
?
一只萌萌小番薯

TA贡献1795条经验 获得超7个赞

你好!1)nginx是一个静态资源服务器2)nginx只是将php的一些请求信息转发给fastcgi这个进程管理器,然后再转交给php-fpm3)php-fpm会将资源转给php脚本解析服务器的wrapper4)你需要添加如下配置
location~\.php${
#roothtml;//这个是你网站的目录,你要定义在server层,$document_root或者就是这个变量
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
                            
查看完整回答
反对 回复 2019-05-21
  • 2 回答
  • 0 关注
  • 3191 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信