自己的生产环境:centos7,openresty,php,mysql出现的问题:IP访问是正常的,输入ip/install显示403Forbidden,我给/usr/local/openresty/nginx/html目录权限改为777还是不行,请问怎么解决这个问题呢?刚刚发现,50x.html也可以显示,但是ip/install/index.php不能显示.如果我访问myipadress/install/index.php,结果是下载这个文件,请问怎么设置才能正确访问index.php呢?error.log显示:2018/06/0810:33:18[error]12018#12018:*334directoryindexof"/usr/local/openresty/nginx/html/install/"isforbidden,自己的nginx.conf配置:userroot;worker_processes1;#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo;#pidlogs/nginx.pid;events{worker_connections1024;}http{includemime.types;default_typeapplication/octet-stream;#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'#'$status$body_bytes_sent"$http_referer"'#'"$http_user_agent""$http_x_forwarded_for"';#access_loglogs/access.logmain;sendfileon;#tcp_nopushon;client_max_body_size8m;#允许客户端请求的最大单文件字节数client_body_buffer_size2m;#缓冲区代理缓冲用户端请求的最大字节#WAFlua_shared_dictlimit50m;#防cc使用字典,大小50Mlua_shared_dictguard_dict100m;lua_shared_dictdict_captcha70m;lua_max_running_timers1;lua_package_path"/usr/local/openresty/nginx/conf/waf/?.lua";init_by_lua_file"/usr/local/openresty/nginx/conf/waf/init.lua";access_by_lua_file"/usr/local/openresty/nginx/conf/waf/access.lua";#keepalive_timeout0;keepalive_timeout65;gzipon;server{listen80;listen[::]:80default_server;server_namemyipaddress;#charsetkoi8-r;#access_loglogs/host.access.logmain;location/{roothtml;indexindex.htmlindex.htmindex.php;}location/phpmyadmin{alias/usr/share/phpMyAdmin;indexindex.php;}location~/phpmyadmin/.+\.php${if($fastcgi_script_name~/phpmyadmin/(.+\.php.*)$){set$valid_fastcgi_script_name$1;}includefastcgi_params;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME/usr/share/phpMyAdmin/$valid_fastcgi_script_name;}#error_page404/404.html;#redirectservererrorpagestothestaticpage/50x.html#error_page500502503504/50x.html;location=/50x.html{roothtml;}#这里新加的#PHP脚本请求全部转发到FastCGI处理.使用FastCGI协议默认配置.#Fastcgi服务器和程序(PHP,Python)沟通的协议.location~\.php${#设置监听端口fastcgi_pass127.0.0.1:9000;#设置nginx的默认首页文件(上面已经设置过了,可以删除)fastcgi_indexindex.php;#设置脚本文件请求的路径fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;#引入fastcgi的配置文件includefastcgi_params;}#proxythePHPscriptstoApachelisteningon127.0.0.1:80##location~\.php${#proxy_passhttp://127.0.0.1;#}#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000##location~\.php${#roothtml;#fastcgi_pass127.0.0.1:9000;#fastcgi_indexindex.php;#fastcgi_paramSCRIPT_FILENAME/document_root$fastcgi_script_name;#includefastcgi_params;#}#denyaccessto.htaccessfiles,ifApache'sdocumentroot#concurswithnginx'sone##location~/\.ht{#denyall;#}}#anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration##server{#listen8000;#listensomename:8080;#server_namesomenamealiasanother.alias;#location/{#roothtml;#indexindex.htmlindex.htm;#}#}#HTTPSserverserver{listen443sslhttp2;server_namemyipaddress;charsetutf-8;sslon;default_typetext/plain;ssl_session_cacheshared:SSL:1m;ssl_session_timeout5m;ssl_protocolsTLSv1TLSv1.1TLSv1.2;ssl_ciphersECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;ssl_prefer_server_cipherson;location/{roothtml;indexindex.htmlindex.htmindex.php;}location~/phpmyadmin/.+\.php${if($fastcgi_script_name~/phpmyadmin/(.+\.php.*)$){set$valid_fastcgi_script_name$1;}includefastcgi_params;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME/usr/share/phpMyAdmin/$valid_fastcgi_script_name;}location~\.php${#设置监听端口fastcgi_pass127.0.0.1:9000;#设置nginx的默认首页文件(上面已经设置过了,可以删除)fastcgi_indexindex.php;#设置脚本文件请求的路径fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;#引入fastcgi的配置文件includefastcgi_params;}}}
2 回答
慕虎7371278
TA贡献1802条经验 获得超4个赞
“如果我访问myipadress/install/index.php,结果是下载这个文件,请问怎么设置才能正确访问index.php呢?”nginx本身不能解析php语言的,应该需要配合对应的模块才能解析Php,否则就当作是一个文件来下载下来了。
添加回答
举报
0/150
提交
取消