【问题标题】:installing a highcharts server with CentOS 6使用 CentOS 6 安装 highcharts 服务器
【发布时间】:2013-04-01 03:59:37
【问题描述】:

我很难找到创建 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

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

【问题讨论】:

    标签: java tomcat installation highcharts centos


    【解决方案1】:

    看来我的做法完全错误。我不需要安装 tomcat、java 或其他任何东西。我安装了fonts、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-08-17
      • 1970-01-01
      • 2013-08-26
      • 2012-07-31
      • 1970-01-01
      • 2013-10-09
      • 1970-01-01
      • 1970-01-01
      • 2014-09-14
      相关资源
      最近更新 更多