0%

Linux 环境搭建

这里我使用的是VM来搭建 Linux 环境. 本片相当于笔记,方便需要安装的时候快速安装.

图1

图2

图3

图4

上面4个步骤执行完成之后,就可以运行虚拟机了,启动系统之后,选择install,进入安装

开始会让你选择语音.

图5

图6

图7

网络设置

参数设置

图8

/etc/sysconfig/network-scripts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=e3cb6139-c98a-4a64-bb64-24cc2c11111b
DEVICE=ens33
ONBOOT=yes
# 虚拟机本机ip 根据需要设置
IPADDR=192.168.1.2
# 网关/路由ip 根据网络设置
GATEWAY=192.168.1.1
# 字码掩码
NETMASK=255.255.255.0
DNS1=8.8.8.8

修改network 文件

修改 /etc/sysconfig/network 文件

1
2
3
4
# Created by anaconda
#
# 网络是否工作,不能为no
NETWORKING=yes

重启网络

1
service network restart 

检查网络状况

执行ping 命令,尝试ping下公网网络,本机网络等

防火墙设置

为了避免不必要的问题 选择关闭防火墙

检查防火墙是否开启; 在窗口中可以看到running 是高亮的.

systemctl status firewalld.service

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@localhost ~]# systemctl status firewalld.service 
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 一 2020-12-14 08:48:46 CST; 41min ago
Docs: man:firewalld(1)
Main PID: 742 (firewalld)
CGroup: /system.slice/firewalld.service
└─742 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

12月 14 08:48:44 localhost.home1 systemd[1]: Starting firewalld - dynamic f....
12月 14 08:48:46 localhost.home1 systemd[1]: Started firewalld - dynamic fi....
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#

关闭防火墙

systemctl stop firewalld

禁止防火墙开机启动

systemctl disable firewalld

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]#
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)

12月 14 08:48:44 localhost.home1 systemd[1]: Starting firewalld - dynamic f....
12月 14 08:48:46 localhost.home1 systemd[1]: Started firewalld - dynamic fi....
12月 14 09:32:23 localhost.home1 systemd[1]: Stopping firewalld - dynamic f....
12月 14 09:32:23 localhost.home1 systemd[1]: Stopped firewalld - dynamic fi....
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#

然后重启检查下.

JAVA 环境

从官网 下载tar.gz 包, 记得注意虚拟机指令集环境.

使用 sftp 上传文件.

1
2
3
4
5
6
root@192.168.1.2's password: 
Connected to 192.168.1.2.
sftp> put /Users/conan/Downloads/jdk-8u271-linux-x64.tar.gz /usr/local
Uploading /Users/conan/Downloads/jdk-8u271-linux-x64.tar.gz to /usr/local/jdk-8u271-linux-x64.tar.gz
/Users/conan/Downloads/jdk-8u271-linux-x64.ta 100% 137MB 23.1MB/s 00:05
sftp>

解压文件

1
[root@localhost local]# tar xzf jdk-8u271-linux-x64.tar.gz 

配置环境变量

修改 /etc/profile 文件, 在文件尾添加如下配置

1
2
3
4
# ev
export JAVA_HOME=/usr/local/jdk1.8.0_271
export JRE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$PATH

检查环境 java -version