IIS环境下 PHP无法显示错误信息怎么办

coldplay.xixi
coldplay.xixi 原创
2023-03-03 19:48:01 2052浏览

IIS环境下 PHP无法显示错误信息的解决办法:1、更改PHP的配置文件【php.ini】;2、在网站的根目录下面新建一个【web.config】文件,并添加相应代码;3、安装组件【VCRUNTIME140.dll】。

IIS环境下 PHP无法显示错误信息的解决办法:

1.PHP

首先打开PHP的配置文件php.ini,并做如下配置修改:

  • log_errors = On

  • html_errors = On

  • display_errors = On

  • fastcgi.logging = 0

  • error_reporting = E_ALL & ~E_NOTICE

相关学习推荐:php图文教程

可根据自己需求修改

  • extension=php_curl.dll 开启CURL模式

  • extension=php_openssl.dll 开启Openssl模式

  • extension=php_pdo_mysql.dll 开启数据库事务处理

  • extension_dir = "C:\php\ext" ; 设置php模块路径

  • date.timezone = PRC/ “Asia/Shanghai” ;设置时区为中国时区

  • short_open_tag = On ; php支持短标签 可选

  • cgi.force_redirect = 0 ; 开启以CGI方式运行php

  • fastcgi.impersonate = 1 ; FastCGI相关设置

  • cgi.rfc2616_headers = 1 ; 为什么要改这一项暂不清楚

  • cgi.fix_pathinfo = 0 ; 将1改为0,为了防止 FastCGI解析漏洞

  • error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ;将错误提醒修改为标准模式

2.Web网站

在网站的根目录下面新建一个web.config文件

添加如下代码:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.webServer>
    <httpErrors errorMode="DetailedLocalOnly" existingResponse="PassThrough"></httpErrors>
  </system.webServer>
  
</configuration>

3.运行cmd进入该目录,执行 PHP 时结果弹出窗口提示:无法启动此程序,因为计算机中丢失 VCRUNTIME140.dll。

Windows下运行php7需要Visual C++Redistributable 2015而之前的版本不需要那么高的,最新版的Apache可能也需要这个组件,这个组件是运行Visual Studio 2015所建立的C++应用的必要组件,安装一下即可解决环境问题,可以直接去微软官网下载安装程序。

相关视频推荐:PHP编程从入门到精通

以上就是IIS环境下 PHP无法显示错误信息怎么办的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
上一条:php isset怎么用 下一条:php echo怎么用