centos7.9上面编译openjdk

9 篇文章 0 订阅
4 篇文章 0 订阅

centos7.9上面编译openjdk

在win10上面centos7.9桌面版本虚拟机

安装VMware

在VMware上面创建centos虚拟机

参考文档就不写了,网上搜索一大堆;
在这里主要强调的是,虚拟机内核版本很重要,不管外面gcc或者make版本如何,都要配合内核版本才能正确运行。
ubuntu20.04内核版本:

(base) caoyong@caoyong1:~$ cat /proc/version
Linux version 5.11.0-38-generic (buildd@lgw01-amd64-041) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021

linux内核5+对于openjdk编译来说,有不兼容的情况,意味着付出很多努力,也不一定能够成功(事实上,我失败了)
对于centos7.9来说

#3.10版本编译jdk兼容性就很好
(base) [cyxinda@centos7 code]$ cat /proc/version
Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020

可以完美的编译jdk

安装python3.6.14

下载:https://www.python.org/ftp/python/3.6.14/Python-3.6.14.tar.xz
安装:

yum install zlib zlib-devel
yum -y install bzip2 bzip2-devel ncurses openssl openssl-devel openssl-static xz lzma xz-devel sqlite sqlite-devel gdbm gdbm-devel tk tk-devel libffi-devel
./configure --prefix=/usr/local/python3 --enable-optimizations  && make && make install
[root@centos7 Python-3.6.14]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@centos7 Python-3.6.14]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

部署mercurial

参考:https://www.cnblogs.com/sea-stream/p/14041361.html
下载地址:wget https://www.mercurial-scm.org/release/mercurial-5.9.2.tar.gz --no-check-certificate
执行如下命令:

(python3.8.11) [cyxinda@centos7 source]$ tar -zxvf mercurial-5.9.2.tar.gz
(python3.8.11) [cyxinda@centos7 source]$ sudo mv mercurial-5.9.2 /var/lib/
[sudo] password for cyxinda:
(base) [cyxinda@centos7 source]$ vim ~/.bashrc
# 在~/.bashrc结尾处添加内容:export PATH=$PATH:$HOME/bin:/var/lib/mercurial-5.9.2
(base) [cyxinda@centos7 source]$ source ~/.bashrc
(base) [cyxinda@centos7 source]$ hg --version
Mercurial Distributed SCM (version 5.9.2)
(see https://mercurial-scm.org for more information)

Copyright (C) 2005-2021 Olivia Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

下载OpenJdk

执行如下命令:

(base) [cyxinda@centos7 code]$ hg clone http://hg.openjdk.java.net/jdk8/jdk8 openjdk8
#等待N长时间继续尝试,知道成功为止
(base) [cyxinda@centos7 code]$ cd openjdk8
(base) [cyxinda@centos7 code]$ bash ./get_source.sh
#等待NN长时间,不断重试,知道成功为止

下载引导JDK

引导jdk必须比要编译的jdk版本低,不能用jdk8
下载jdk7

(base) [cyxinda@centos7 source]$ wget https://download.java.net/openjdk/jdk7u75/ri/jdk_ri-7u75-b13-linux-x64-18_dec_2014.tar.gz
(base) [cyxinda@centos7 source]$ tar -zxvf jdk_ri-7u75-b13-linux-x64-18_dec_2014.tar.gz
(base) [cyxinda@centos7 source]$ sudo mv java-se-7u75-ri /var/lib/
[sudo] password for cyxinda:

编译openJDK

  1. 构建JDK
(base) [cyxinda@centos7 openjdk]$ pwd
/code/source/openjdk
(base) [cyxinda@centos7 openjdk]$ bash ./configure \
> --with-target-bits=64 \
> --with-boot-jdk=/var/lib//java-se-7u75-ri/ \
> --with-debug-level=slowdebug \
> --enable-debug-symbols ZIP_DEBUGINFO_FILES=0

config.status: creating /code/source/openjdk/build/linux-x86_64-normal-server-slowdebug/Makefile
config.status: creating /code/source/openjdk/build/linux-x86_64-normal-server-slowdebug/config.h

====================================================
A new configuration has been successfully created in
/code/source/openjdk/build/linux-x86_64-normal-server-slowdebug
using configure arguments '--with-target-bits=64 --with-boot-jdk=/var/lib/java-se-7u75-ri/ --with-debug-level=slowdebug --enable-debug-symbols ZIP_DEBUGINFO_FILES=0'.

Configuration summary:
* Debug level:    slowdebug
* JDK variant:    normal
* JVM variants:   server
* OpenJDK target: OS: linux, CPU architecture: x86, address length: 64

Tools summary:
* Boot JDK:       openjdk version "1.7.0_75" OpenJDK Runtime Environment (build 1.7.0_75-b13) OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)  (at /var/lib/java-se-7u75-ri)
* C Compiler:     gcc (GCC) 4.8.5 20150623 (Red Hat-44) version 4.8.5-44) (at /usr/bin/gcc)
* C++ Compiler:   g++ (GCC) 4.8.5 20150623 (Red Hat-44) version 4.8.5-44) (at /usr/bin/g++)

Build performance summary:
* Cores to use:   4
* Memory limit:   5786 MB
* ccache status:  not installed (consider installing)

Build performance tip: ccache gives a tremendous speedup for C++ recompilations.
You do not have ccache installed. Try installing it.
You might be able to fix this by running 'sudo yum install ccache'.

如上表明构建成功。

  • 异常1:
    configure: error: Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). You might be able to fix this by running 'sudo yum install libXtst-devel libXt-devel libXrender-devel'.
    运行sudo yum install libXtst-devel libXt-devel libXrender-devel即可解决

  • 异常2:
    configure: error: Could not find cups! You might be able to fix this by running 'sudo yum install cups-devel'. configure exiting with result code 1
    运行sudo yum install cups-devel即可解决

  • 异常3:
    configure: error: Could not find freetype! You might be able to fix this by running ‘sudo yum install freetype-devel’.
    configure exiting with result code 1

    configure: error: Could not find alsa! You might be able to fix this by running ‘sudo yum install alsa-lib-devel’.
    configure exiting with result code 1

  1. 编译openjdk
(base) [cyxinda@centos7 openjdk]$ make all ZIP_DEBUGINFO_FILES=0
#要等待N长时间,期间要安装N多依赖才能编译成功
#   com.sun.nio.sctp
## Finished docs (build time 00:02:27)

----- Build times -------
Start 2021-10-16 04:30:21
End   2021-10-16 04:41:47
00:00:29 corba
00:00:18 demos
00:02:27 docs
00:02:51 hotspot
00:00:30 images
00:00:19 jaxp
00:00:29 jaxws
00:03:10 jdk
00:00:37 langtools
00:00:16 nashorn
00:11:26 TOTAL
-------------------------
Finished building OpenJDK for target 'all'

(base) [cyxinda@centos7 openjdk]$ ./build/linux-x86_64-normal-server-slowdebug/jdk/bin/java version
Error: Could not find or load main class version
(base) [cyxinda@centos7 openjdk]$ ./build/linux-x86_64-normal-server-slowdebug/jdk/bin/java -version
openjdk version "1.8.0-internal-debug"
OpenJDK Runtime Environment (build 1.8.0-internal-debug-cyxinda_2021_10_16_04_28-b00)
OpenJDK 64-Bit Server VM (build 25.0-b70-debug, mixed mode)

上述表明openjdk编译成功
运行测试:

(base) [cyxinda@centos7 openjdk]$ vim Test.java
(base) [cyxinda@centos7 openjdk]$ cat Test.java
public class Test{
        public static void main(String[] args){
                System.out.println("Hello World");
        }
}
(base) [cyxinda@centos7 openjdk]$ ./build/linux-x86_64-normal-server-slowdebug/jdk/bin/javac Test.java
(base) [cyxinda@centos7 openjdk]$ ./build/linux-x86_64-normal-server-slowdebug/jdk/bin/java Test
Hello World

安装eclipse

可以参考:https://www.cnblogs.com/biem/p/12923263.html

  • 下载eclipse:https://www.eclipse.org/downloads/packages/
    点击>> Select Another Mirror,选择一个国内的镜像线路,下载速度会快一些https://mirrors.nju.edu.cn/eclipse//technology/epp/downloads/release/2021-12/R/eclipse-cpp-2021-12-R-linux-gtk-x86_64.tar.gz
  • 下载完成后,进入下载目录,打开终端,解压下载好的Eclipse到usr/local/下
    $ sudo tar -xzvf eclipse-jee-2020-03-R-incubation-linux-gtk-x86_64.tar.gz -C /usr/local/
    
  • 使用软连接启动Eclipse
    解压完毕后,进入/usr/local/bin/目录,建立eclipse的软连接,方便我们以后在终端打开eclipse,就像在终端开启vscode一样
    $ cd /usr/local/bin/ && sudo ln -s /usr/local/eclipse/eclipse
    
  • 使用桌面快捷方式启动Eclipse
    或者设置Eclipse的快捷方式,像在Windows桌面一样打开Eclipse
    进入/usr/share/applications文件夹,该文件夹就相当于Windows上的快捷方式
    $ cd /usr/share/applications
    新建一个Eclipse的快捷方式
    sudo tee eclipse.desktop <<-'EOF'
    [Desktop Entry]
    Encoding=UTF-8
    Name=Eclipse
    Comment=Eclipse IDE
    Exec=/usr/local/eclipse/eclipse
    Icon=/usr/local/eclipse/icon.xpm
    Terminal=false
    Type=Application
    Categories=GNOME;Application;Development;
    StartupNotify=true
    EOF
    
    现在打开usr/share/applacations目录就可以看见Eclipse的快捷方式了,将其复制到桌面,即可通过桌面快捷方式启动Eclipse
  • 到桌面上面,点击eclipse就可以启动了
    在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是centos7.9编译安装nginx的步骤: 1. 安装编译nginx所需的依赖库: ``` yum install -y gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxslt libxslt-devel gd gd-devel perl perl-devel perl-ExtUtils-Embed ``` 2. 下载nginx源码包: 可以到官网(https://nginx.org/en/download.html)下载最新的稳定版nginx源码包。 3. 解压源码包: ``` tar zxvf nginx-xxx.tar.gz ``` 4. 进入nginx源码目录,执行以下命令进行编译和安装: ``` ./configure --with-http_stub_status_module --with-http_ssl_module make && make install ``` 其中,--prefix参数指定nginx安装目录,--with-http_stub_status_module参数启用状态页模块,--with-http_ssl_module参数启用SSL加密支持。 5. 配置nginx: 进入/usr/local/nginx/conf目录,编辑nginx.conf文件,进行配置。这里给出一个简单的配置文件示例: ``` user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /usr/local/nginx/conf/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /usr/local/nginx/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/local/nginx/html; } } server { listen 443 ssl; server_name localhost; ssl_certificate /usr/local/nginx/conf/server.crt; ssl_certificate_key /usr/local/nginx/conf/server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root /usr/local/nginx/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/local/nginx/html; } } } ``` 其中,listen参数指定监听端口,server_name参数指定域名,root参数指定网站根目录,ssl_certificate和ssl_certificate_key参数指定SSL证书和私钥文件路径。 6. 启动nginx: 进入/usr/local/nginx/sbin目录,执行以下命令启动nginx: ``` ./nginx ``` 7. 检查nginx是否启动成功: 执行以下命令查看nginx进程是否存在: ``` ps -ef | grep nginx ``` 执行以下命令检查nginx监听的端口是否打开: ``` netstat -tlnp | grep nginx ``` 如果输出类似以下内容,则说明nginx已经成功安装并启动: ``` tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN xxxx/nginx tcp 0 0 :::443 :::* LISTEN xxxx/nginx ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值