�忘了� 2019-01-09 09:28 采纳率: 0%
浏览 983

tp5部署到IIS上报Fatal error

Fatal error: Uncaught exception 'think\exception\ErrorException' with message 'Undefined index: REQUEST_URI' in D:\www\web\ceshi10.com_TtLIkrREPMyRzNlX0LnW\wwwroot\tp\thinkphp\library\think\log\driver\File.php:100 Stack trace: #0 D:\www\web\ceshi10.com_TtLIkrREPMyRzNlX0LnW\wwwroot\tp\thinkphp\library\think\log\driver\File.php(100): think\Error::appError(8, 'Undefined index...', 'D:\www\web\cesh...', 100, Array) #1 D:\www\web\ceshi10.com_TtLIkrREPMyRzNlX0LnW\wwwroot\tp\thinkphp\library\think\log\driver\File.php(80): think\log\driver\File->write('[ info ] [ LANG...', 'D:\www\web\cesh...') #2 D:\www\web\ceshi10.com_TtLIkrREPMyRzNlX0LnW\wwwroot\tp\thinkphp\library\think\Log.php(179): think\log\driver\File->save(Array) #3 D:\www\web\ceshi10.com_TtLIkrREPMyRzNlX0LnW\wwwroot\tp\thinkphp\library\think\Error.php(93): think\Log::save() #4 [internal function]: think\Error::appShutdown() #5 {main} thrown in D:\www\web\ceshi10.com_TtLIkrREPMyRzNlX0LnW\wwwroot\tp\thinkphp\library\think\log\driver\File.php on line 100

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-08-07 16:20
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    根据您提供的错误信息,这可能是因为在PHP的配置中没有正确地设置REQUEST_URI变量。REQUEST_URI是PHP中的一个内置变量,用于获取当前请求的URL。

    要解决此问题,请确保您的PHP服务器上已经启用了REQUEST_URI变量,并且在应用程序中正确设置了这个变量。通常,在Apache或Nginx等Web服务器中,可以通过以下方式启用REQUEST_URI

    对于Apache:

    # 在Apache的httpd.conf文件中添加以下行以启用REQUEST_URI
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
    </IfModule>
    

    然后,在您的PHP脚本中使用$_SERVER['REQUEST_URI']来访问当前请求的URL。

    对于Nginx:

    server {
        listen 80 default_server;
        server_name yourdomain.com;
    
        location / {
            try_files $uri $uri/ =404;
        }
    
        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_pass unix:/path/to/php-fpm.sock;
        }
    }
    

    然后,在您的PHP脚本中使用$_SERVER['DOCUMENT_ROOT']来访问当前请求的URL。

    确保将上述代码中的yourdomain.com替换为实际的域名和端口,以及/path/to/php-fpm.sock替换为您希望使用的PHP-FPM服务监听的路径。

    此外,您还可以通过修改HTTP headers来直接在PHP脚本中访问REQUEST_URI,例如通过设置HTTP_HOSTSCRIPT_NAMEQUERY_STRING来间接访问。

    如果您正在使用的是其他类型的Web服务器(如Lighttpd),则需要查看其文档来了解如何启用REQUEST_URI并将其与PHP集成。

    评论

报告相同问题?