【问题标题】:phpCHART with apache virtual port does not work带有 apache 虚拟端口的 phpCHART 不起作用
【发布时间】:2020-01-02 12:08:45
【问题描述】:

我正在尝试使用 apache 虚拟端口设置 phpCHART。 我已按照以下说明操作:https://phpchart.com/examples/ 我确实注意到下面提到的错误消息中有一些额外的 [/],但从 conf.php 中定义的路径中删除 [/] 并没有帮助。

问题:

假设按照说明进行操作,我的设置是否有明显问题?


一些检查:

  • phpChartLite 被提取并移动到 [/var/www/phpChart_Lite]。
  • 我已检查 [/var/www/phpChart_Lite] 的权限。
  • 我可以访问 [localhost:1000] 并从 [/var/www/phpChart_Lite] 查看文件结构。
  • 确保 index.php 确实包含来自 conf.php。

[/var/www/phpChart_Lite] 中的 conf.php。

define('SCRIPTPATH', '/phpChart_Lite/');
define('DEBUG', true);
require_once('phpChart.php');

索引文件的位置:

[/var/www/phpChart_Lite/test/index.php]

索引文件内容:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

    <?php

    require_once('../conf.php');

    $pc = new C_PhpChartX(array(array(11, 9, 5, 12, 14)), 'basic_chart');
    $pc->draw();

    ?>

</body>
</html>

apacahe虚拟端口的配置。

(/etc/apache2/sites-enabled/000-default.conf):

<VirtualHost *:1000>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/phpChart_Lite
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/etc/apache2/ports.conf

Listen 1000

错误信息:

Warning: require_once(/var/www/phpChart_Lite//phpChart//conf.php): failed to open stream: No such file or directory in /var/www/phpChart_Lite/server/cls_conf.php(1) : eval()'d code(1) : eval()'d code on line 5

Fatal error: require_once(): Failed opening required '/var/www/phpChart_Lite//phpChart//conf.php' (include_path='.:/usr/share/php') in /var/www/phpChart_Lite/server/cls_conf.php(1) : eval()'d code(1) : eval()'d code on line 5

【问题讨论】:

  • 不应该 SCRIPTPATH 为空,因为您的文档根目录设置在文件夹内? (只是通过文档,从未使用过这个,可能永远不会)。
  • @Jonnix 有意义,因为当我从 SCRIPTPATH 中删除 [/] 时,我得到了两次 [phpChart_Lite]。
  • @Jonnix 您的建议解决了这个问题。文件夹结构中的所有示例现在都可以使用。该图仍有一些问题没有完全呈现,但这不是这个问题的一部分。请将您的评论移至答案,我会接受答案。

标签: php graph charts


【解决方案1】:

查看示例页面,有一条针对SCRIPTPATH 定义的评论(在无用的配色方案中)指出:

// /phpChart/ is the absolute path to the phpChart files assuming phpChart folder is a folder in the web root.

由于 DocumentRoot 设置在 phpChart 文件夹内(或在本例中为 phpChart_Lite),因此 SCRIPTPATH 可能应该设置为 / 或为空以修复路径。

【讨论】:

    猜你喜欢
    • 2021-05-03
    • 2014-07-17
    • 2018-05-09
    • 2015-11-15
    • 2014-12-02
    • 2021-09-10
    • 2022-01-12
    • 2015-10-23
    • 1970-01-01
    相关资源
    最近更新 更多