1

我很难找到一个好的教程来创建一个 highcharts 服务器。他们的安装页面似乎没有所需的内容。

http://docs.highcharts.com/#installation

这个 github 页面看起来更接近我所需要的,但我对 Tomcat 很陌生,并且在关注它时遇到了麻烦

https://github.com/highslide-software/highcharts.com/tree/master/exporting-server/java

到目前为止我所拥有的:

 #!/bin/bash

 #allow access for tomcat
 /sbin/iptables -I INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
 echo "[OK]"
 echo -n "Saving new rules"
 (/etc/init.d/iptables save &&  echo "[OK]") || echo "[FAILED]"
 service iptables restart

 yum -y install tomcat6*
 yum -y install java-1.7.0-openjdk java-1.7.0-openjdk-devel
 service tomcat6 start
 chkconfig --levels 35 tomcat6 on

 wget http://download.nextag.com/apache/maven/maven-3/3.0.5/binaries/apache-maven-3.0.5-bin.tar.gz
 tar -xzvf apache-maven-3.0.5-bin.tar.gz
 mv apache-maven-3.0.5/ /usr/local/
 echo 'export PATH=/usr/local/apache-maven-3.0.5/bin:$PATH' >> /etc/profile.d/maven.sh

 yum -y install freetype freetype-devel
 yum -y install fontconfig fontconfig-devel

 wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
 tar -xjvf phantomjs-1.9.0-linux-x86_64.tar.bz2

 yum -y install ant-* ant-apache* ant-commons-logging
 yum -y install git

 git clone https://github.com/highslide-software/highcharts.com.git
 cd highcharts.com
 ant assemble
 ant lint
 ant build

我想我需要编译highcharts,然后将它移动到tomcat目录/var/lib/tomcat6/webapps。但是当我运行 ant build 时出现错误

 # ant build
 Buildfile: build.xml

 set.properties:

 clean:
     [mkdir] Created dir: /root/highcharts.com/build/dist/js/adapters
     [mkdir] Created dir: /root/highcharts.com/build/dist/js/modules
     [mkdir] Created dir: /root/highcharts.com/build/dist/highcharts/gfx
     [mkdir] Created dir: /root/highcharts.com/build/dist/highcharts/js/adapters
     [mkdir] Created dir: /root/highcharts.com/build/dist/highcharts/js/modules
     [mkdir] Created dir: /root/highcharts.com/build/dist/highstock/gfx
     [mkdir] Created dir: /root/highcharts.com/build/dist/highstock/js/adapters
     [mkdir] Created dir: /root/highcharts.com/build/dist/highstock/js/modules
     [mkdir] Created dir: /root/highcharts.com/build/tests
     [mkdir] Created dir: /root/highcharts.com/build/coverage-report

 assemble:

 check-crlf:

 do-lint:

 lint:

 minify:

 compile:

 BUILD FAILED
 /root/highcharts.com/build.xml:378: The following error occurred while executing this line:
 /root/highcharts.com/build.xml:336: java.lang.ClassNotFoundException: org.apache.bsf.engines.javascript.JavaScriptEngine

 Total time: 9 seconds

但老实说,我什至不确定我是否以正确的方式处理这件事。我在正确的轨道上吗?有什么建议么?

4

1 回答 1

1

看起来我完全错误地处理了这个问题。我不需要安装 tomcat、java 或其他任何东西。我安装了字体、phantomjs 和 highcharts,并且可以通过 apache 发送 Web 请求来生成图表。

这是我的设置脚本:

    #!/bin/bash
    /sbin/iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
    echo "[OK]"
    echo -n "Saving new rules"
    (/etc/init.d/iptables save &&  echo "[OK]") || echo "[FAILED]"
    service iptables restart
    service httpd start
    chkconfig --levels 35 httpd on


    yum -y install urw-fonts

    wget -O /root/phantomjs-1.9.0-linux-x86_64.tar.bz2
    https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
    tar -C /root/ -xjvf /root/initial_install/phantomjs-1.9.0-linux-x86_64.tar.bz2
    cp /root/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/local/bin/


    cd /var/www/html
    wget http://www.highcharts.com/downloads/zips/Highcharts-3.0.1.zip
    unzip Highcharts-3.0.1.zip
    mkdir /var/www/html/exporting-server/phantomjs/tmp
    chmod 777 /var/www/html/exporting-server/phantomjs/tmp

    perl -pi -e 's/phantomjs\/highcharts-convert.js/\/var\/www\/html\/exporting-server\/phantomjs\/highcharts-convert.js/g' /var/www/html/exporting-server/php/php-phantomjs/index.php
    perl -pi -e "s/phantomjs\/tmp/\/var\/www\/html\/exporting-server\/phantomjs\/tmp/g" /var/www/html/exporting-server/php/php-phantomjs/index.php

    perl -pi -e "s/highstock.js/\/var\/www\/html\/exporting-server\/java\/highcharts-export\/src\/main\/webapp\/WEB-INF\/phantomjs\/highstock.js/g" /var/www/html/exporting-server/phantomjs/highcharts-convert.js
    perl -pi -e "s/highstock-more.js/\/var\/www\/html\/js\/highcharts-more.js/g" /var/www/html/exporting-server/phantomjs/highcharts-convert.js
    perl -pi -e "s/jquery-1.8.2.min.js/\/var\/www\/html\/exporting-server\/java\/highcharts-export\/src\/main\/webapp\/WEB-INF\/phantomjs\/jquery-1.8.2.min.js/g" /var/www/html/exporting-server/phantomjs/highcharts-convert.js

这是可以生成图表的示例 PHP:

(填写 /exporting-server/php/php-phantomjs/demo.html 中的 $hc_options 和 $hc_svg)

    <?php
    $url = 'http://highcharts-server/exporting-server/php/php-phantomjs/index.php';
    $filename = 'test.png';

    $hc_options = <<<EOF
    EOF;
    $hc_svg = <<<EOF
    EOF; 
    $hc_type = 'image/png';
    $hc_width = '600';
    $hc_scale = '';
    $hc_product = 'highcharts';
    $hc_callback = "function(){alert('hallo from highcharts')}";

    $post_data = array('options'=>$hc_options,'svg'=>$hc_svg,'type'=>$hc_type,'width'=>$hc_width,'scale'=>$hc_scale,'product'=>$hc_product,'callback'=>$hc_callback);
    $curl_data = http_build_query($post_data);

    $options[CURLOPT_RETURNTRANSFER] = true; // return web page
    $options[CURLOPT_HEADER] = false; // don't return headers 
    $options[CURLOPT_FOLLOWLOCATION] = true; // follow redirects
    $options[CURLOPT_ENCODING] = ""; // handle all encodings
    $options[CURLOPT_USERAGENT] = "ap testing highcharts"; // who am i
    $options[CURLOPT_AUTOREFERER] = true; // set referer on redirect
    $options[CURLOPT_CONNECTTIMEOUT] = 10; // timeout on connect
    $options[CURLOPT_TIMEOUT] = 20; // timeout on response
    $options[CURLOPT_MAXREDIRS] = 10; // stop after 10 redirects

    $options[CURLOPT_POST] = 1; // i am sending post data
    $options[CURLOPT_POSTFIELDS] = $curl_data; // the post data in get format (e.g. name=Bob&age=12

    $options[CURLOPT_SSL_VERIFYHOST] = 0;
    $options[CURLOPT_SSL_VERIFYPEER] = false; 

    #$options[CURLOPT_VERBOSE] = 1; // outputs the web page

    $ch      = curl_init($url); 
    curl_setopt_array($ch,$options);

    $content = curl_exec($ch); 
    $err     = curl_errno($ch);
    $errmsg  = curl_error($ch) ;
    $header  = curl_getinfo($ch);
    curl_close($ch);

    file_put_contents($filename, $content);
    ?>
于 2013-05-09T18:19:02.857 回答