zoukankan      html  css  js  c++  java
  • Ubuntu 安装java环境搭建

    1、下载JDK 8
    http://www.oracle.com/technetwork/java/javasebusiness/downloads/选择下载JDK的最新版本 JDK 8。

    2、解压文件
    $ sudo mkdir /usr/lib/jvm
    $ sudo mv jdk-8u11-linux-x64.tar.gz /usr/lib/jvm/

    $ cd /usr/lib/jvm/
    $ sudo tar -zxvf jdk-8u11-linux-x64.tar.gz
    $ rm ./jdk-8u11-linux-x64.tar.gz

    3、配置

    $ sudo gedit /etc/environment

    报错:(gedit:7473): Gtk-WARNING **: cannot open display: 

    运行xhost +

    xhost:  unable to open display ""

    总之用网上各种方法均不见效,最后用vim /etc/environmen

    JAVA_HOME="/usr/lib/jvm/jdk1.8.0_11"

    CLASSPATH=".:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar"

    然后就是要告诉系统,我们使用的sun的JDK,而非OpenJDK了:

    sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_11/bin/java 300

    sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_11/bin/javac 300

    4. 测试一下运行 java -version

    root@iZ23htt4xm4Z:/etc# java -version
    java version "1.8.0_11"
    Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

    java安装完成下一步

    下载安装最新版本的Tomcat

    从tomcat的官方下载页面

    http://tomcat.apache.org/download-70.cgi

    下载Binary->Core分类中的zip或者tar.gz包后,本地解压缩并将新生成的目录重命名为tomcat,以方便使用。将这个文件夹移动至某路径PATH/。 参考以上设置环境变量和端口设置等步骤,大功告成! 直接运行

    PATH/tomcat/bin/./startup.sh

    Tomcat 便即刻在后台服务了。 (请将PATH替换成适合您的路径)

    下载maven

    设置环境变量

     M2_HOME=/home/weibo/apache-maven-3.0.5
     M2=$M2_HOME/bin
     PATH=$M2:$PATH

    保存 

    source /etc/environmen

    测试

    mvn -version

    root@iZ23htt4xm4Z:/usr/lib/jvm# mvn -version
    Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T21:51:42+08:00)
    Maven home: /usr/lib/jvm/maven
    Java version: 1.8.0_11, vendor: Oracle Corporation
    Java home: /usr/lib/jvm/jdk1.8.0_11/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "3.13.0-30-generic", arch: "amd64", family: "unix"

    maven安装完成

    apache安装

    官网下载httpd-2.4.10.tar.gz

    $ gzip -d httpd-2.4.10.tar.gz
    $ tar xvf httpd-2.4.10.tar.gz
    $ cd httpd-2.4.10.tar.gz

    ./configure --prefix=/usr/lib/jvm/apache 

    root@iZ23htt4xm4Z:/usr/lib/jvm/httpd-2.4.10# ./configure --prefix=/usr/lib/jvm/apache
    checking for chosen layout... Apache
    checking for working mkdir -p... yes
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking target system type... x86_64-unknown-linux-gnu
    configure:
    configure: Configuring Apache Portable Runtime library...
    configure:
    checking for APR... no
    configure: error: APR not found. Please read the documentation.

    用Apache搭www服务时“APR not found”(APR-Util not found)的解决办法

    原来以为很简单的事,操作起来还是会遇到很多问题,这个问题很典型,调出来与大家分享。

    #./configure —prefix……检查编辑环境时出现:
    checking for APR… no
    configure: error: APR not found .  Please read the documentation.

    可以用./configure –help | grep apr 查看帮助。
    —with-included-apr     Use bundled copies of APR/APR-Util
    —with-apr=PATH         prefix for installed APR or the full path to apr-config
    —with-apr-util=PATH    prefix for installed APU or the full path to
    安装APR(Apache Portable Runtime )
    [root@localhost 52lamp]# tar -zxvf apr-1.5.1.tar.gz //unzip -o apr-apr-1.5.1.zip
    [root@localhost 52lamp]# cd apr-apr-1.5.1
    [root@localhost apr-1.5.1]# ./configure
    [root@localhost apr-1.5.1]# make
    [root@localhost apr-1.5.1]# make install

    再次检查编译环境出现
    checking for APR-util… no
    configure: error: APR-util not found .  Please read the documentation.

    [root@localhost  httpd-httpd-2.4.10]# ./configure –help | grep apr-util
    —with-apr-util=PATH    prefix for installed APU or the full path to

    [root@localhost 52lamp]# tar -zxvf apr-util-1.3.9.tar.gz
    [root@localhost 52lamp]# cd apr-util-1.3.9
    [root@localhost apr-util-1.3.9]# ./configure —prefix=/usr/local/apr-util —with-apr=/usr/local/apr
    [root@localhost apr-util-1.3.9]# make
    [root@localhost apr-util-1.3.9]# make install

    ./configure仍提示APR-util not found,增加—with-apr=/usr/local/apr —with-apr-util=/usr/local/apr-util后出现
    configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

    [root@localhost  httpd-2.4.10]# ./configure –help | grep pcre
    —with-pcre=PATH        Use external PCRE library

    [root@localhost 52lamp]# unzip -o pcre-8.10.zip
    [root@localhost 52lamp]# cd pcre-8.10
    [root@localhost cd pcre-8.35]# ./configure —prefix=/usr/local/pcre
    [root@localhost cd pcre-8.35]# make
    [root@localhost cd pcre-8.35]# make install

    继续安装Apache/httpd,./configure 时加上参数 —with-apr=/usr/local/apr/ —with-apr-util=/usr/local/apr-util/ —with-pcre=/usr/local/pcre,这个问题就解决了。

    注:方法从网上搜到看到的,不是原创

    启动apache

    root@iZ23htt4xm4Z:/usr/lib/jvm/apache/bin# apachectl -k start
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.171.250.114. Set the 'ServerName' directive globally to suppress this message

    vi conf/httpd.conf
    加入一句 ServerName localhost:80
  • 相关阅读:
    spring boot2X集成spring cloud config
    Spring boot配置文件application.properties和bootstrap.properties的区别
    (原)linux下caffe模型转tensorflow模型
    (原)torch7中指定可见的GPU
    (原)使用tensorboard显示loss
    (原)tensorflow保存模型及载入保存的模型
    (原)ubuntu挂载及开机自动挂载网络端的文件夹的方法
    (原+转)win7上编译caffe支持python及matlab
    (原)ubuntnu中anaconda的g++提示crtbeginS.o:unrecognized relocation
    (原)PyTorch中使用指定的GPU
  • 原文地址:https://www.cnblogs.com/hughtxp/p/3879223.html
Copyright © 2011-2022 走看看