- 概述:
- JDK环境配置
- 1.下载jdk8的rpm包
- 2.检查是否存在jdk环境
- 3.rpm命令安装jdk
- 4.环境变量配置
- rpm方式安装jdk不需要配置环境变量
- 普通方式安装配置环境变量
- 5.项目运行测试
- 6.手动结束进程
- 解压缩安装:tomcat
- 1.官网下载tomcat
- 2.上传到服务器目录下
- 3.解压缩
- 4.启动tomcat启动与关闭
- 5.关于虚拟机中的tomcat启动成功但是无法在主机或者其他主机上访问的问题
- 防火墙如何开放端口
- Docker(yum安装)
- 说明:
- 1.检测当前系统版本
- 2.卸载旧版本:Uninstall old versions
- 3.安装准备环境
- 4.Installation methods 安装方法
- (1)Set up the repository 设置存储库
- (2)Install Docker Engine 安装 Docker 引擎
- (3)Start Docker 启动 Docker
- (4)测试是否安装成功
安装开发环境的三种方式
- rpm:以jdk为例
- 解压缩:tomcat
- yum在线安装:docker
2.检查是否存在jdk环境https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html
3.rpm命令安装jdkrpm -qa|grep jdk #检查环境
rpm -e --nodeps jdk_ #卸载
4.环境变量配置 rpm方式安装jdk不需要配置环境变量rpm -ivh rpm文件
注意!rpm方式安装jdk不需要配置环境变量,因此请跳过直接到测试jar文件
为何不用配置,进入/usr/bin时发现了这些命令
也就是说,将jdk安装目录下的bin下的java、javac等命令“复制”到了这里,当然这不是简单的复制,但道理就是那个道理。所以,也就是说,当我们在任意的位置执行java相关命令时,系统会到/usr/bin中来执行。
所以就可以理解为:/usr/bin是针对RPM安装的软件的profile文件,RPM安装过程会自动将一些可执行文件添加到/usr/bin里,从而“配置了环境”,而不需我们配置路径到profile里。
在执行Java某一个命令时,若其按照RPM方式安装,就到/usr/bin下寻找该命令,找到便执行;
若其是按照普通方式安装,就到profile文件里配置的路径下寻找该命令,找到便执行。
JDK环境变量的说明:
JAVA_HOME =你的JDK安装位置
CLASSPATH = .;%JAVA_HOME%lib
PATH = %JAVA_HOME%bin
第一个JAVA_HOME主要是给后面两个环境变量使用的。
第二个CLASSPATH指定的是默认的类库的位置,如上设置,为当前目录和JAVA_HOME的lib目录
第三个PATH是把java的bin加入到系统路径中,这样在命令行或其他程序全局调用java,javac, javaw等命令了。
(1) 编辑环境变量,注意地址是自己的路径
vim /etc/profile
JAVA_HOME=/usr/java/jdk1.8.0_221-amd64 CLASSPATH=%JAVA_HOME%/lib;%JAVA_HOME%/jre/lib PATH=$JAVA_HOME/bin;$JAVA_HOME/jre/bin export PATH CLASSPATH JAVA_HOME
(2) 使配置文件生效并且测试
5.项目运行测试source /etc/profile
6.手动结束进程java -jar 项目名
可以成功运行!
命令:
解压缩安装:tomcat 1.官网下载tomcatkill -9 pid
2.上传到服务器目录下 3.解压缩https://tomcat.apache.org/download-90.cgi
以当前最新版本为例:apache-tomcat-9.0.62.tar.gz
4.启动tomcat启动与关闭命令:tar -zxvf apache-tomcat-9.0.62.tar.gz
./start.sh #启动tomcat
./shutdown.sh #关闭tomcat
执行启动命令
浏览器访问测试否启动成功,出现此页面表示成功
首先查看防火墙状态
systemctl status firewalld
开启防火墙 systemctl start firewalld
关闭防火墙 systemctl stop firewalld
查看已开放的端口:firewall-cmd --list-ports
开放端口:
firewall-cmd --add-port=3306/tcp --permanent
–add-port #添加端口,格式:端口/通讯协议
–permanent #永久生效,否则参数重启后失效
firewall-cmd --reload #防火墙重新加载配置
以官方文档和最新的版本为例
docker官网:https://docs.docker.com/engine/install/centos/
官方文档:
OS requirements
To install Docker Engine, you need a maintained version of CentOS 7 or 8. Archived versions aren’t supported or tested.
The centos-extras repository must be enabled. This repository is enabled by default, but if you have disabled it, you need to re-enable it.
要安装 Docker Engine,你需要一个 CentOS 7或8的维护版本。
必须启用 centos-extras 存储库。此存储库默认是启用的,但是如果您已经禁用了它,则需要重新启用它。
[root@localhost bin]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.
旧版本的 Docker 被称为 Docker 或 Docker-engine。如果已经安装了它们,请卸载它们以及相关的依赖项。
yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-engine
3.安装准备环境
yum -y install gcc-c++
官方文档:
Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach.
大多数用户建立了 Docker 的存储库并从中安装,以便于安装和升级任务。这是推荐的方法。
Install the yum-utils package (which provides the yum-config-manager utility) and set up the stable repository.
安装 yum-utils 包(它提供 yum-config-manager 实用工具)并设置稳定存储库。
sudo yum install -y yum-utils
sudo yum-config-manager
--add-repo
https://download.docker.com/linux/centos/docker-ce.repo
(2)Install Docker Engine 安装 Docker 引擎
Install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
安装最新版本的 Docker Engine 和 containerd,或者进入下一步安装一个特定版本:
yum install docker-ce docker-ce-cli containerd.io
sudo systemctl start docker(4)测试是否安装成功
Verify that Docker Engine is installed correctly by running the hello-world image.
通过运行 hello-world 映像来验证 Docker Engine 安装是否正确。
sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.
此命令下载测试映像并在容器中运行它。当容器运行时,它打印一条消息并退出。
This installs and runs Docker Engine. Use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.
这将安装并运行 Docker 引擎。使用 sudo 运行 Docker 命令。继续安装 Linux 后,允许非特权用户运行 Docker 命令和其他可选配置步骤。



