CentOS7系统安装及基础环境配置

目录

前言

一、VMware安装CentOS7系统

二、基础环境配置

登录系统设置静态网络

ssh工具连接

修改主机名

关闭防火墙、selinux

安装常用软件包

配置国内YUM源及拓展源

快照


前言

CentOS(Community Enterprise Operating System,中文意思是社区企业操作系统)是Linux发行版之一,它是来自于Red Hat Enterprise Linux依照开放源代码规定释出的源代码所编译而成。由于出自同样的源代码,因此有些要求高度稳定性的服务器以CentOS替代商业版的Red Hat Enterprise Linux使用。两者的不同,在于CentOS完全开源

CentOS官网:The CentOS Projecthttps://www.centos.org/

一、VMware安装CentOS7系统

使用默认配置安装

选择安装

默认英文,可以选择中文

时区设置为上海

默认最小化安装,这里我们也使用最小化安装

默认自动分区,也可以手动配置,这里选择默认

设置完后开始安装

​​ 

设置root用户密码,可以不用创建普通用户

设置密码后点两次完成退出

等待安装完成

完成后重启

二、基础环境配置

登录系统设置静态网络

测试能否ping通外网

 

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33 
[root@localhost ~]# systemctl restart network
[root@localhost ~]# ping -c www.baidu.com
PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data.
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=128 time=17.4 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=128 time=17.2 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=128 time=16.8 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=4 ttl=128 time=16.8 ms


--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3007ms
rtt min/avg/max/mdev = 16.879/17.106/17.409/0.281 ms

ssh工具连接

新建会话,设置名称添加主机ip

输入用户名密码登录

双击连接新建的会话

修改主机名

使用hostnamectl set-hostname [主机名] 命令修改,也可以编辑/etc/hostname文件修改

修改后使用bash或者重新连接会话就会显示主机名已经更改

[root@localhost ~]# hostnamectl set-hostname centos
[root@localhost ~]# vi /etc/hostname 
[root@localhost ~]# bash
[root@centos ~]# 

关闭防火墙、selinux

永久关闭防火墙和selinux,setenforce 0 命令可以临时关闭

[root@centos ~]# systemctl stop firewalld
[root@centos ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@centos ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

安装常用软件包

wget:下载软件包工具

vim:编辑器

net-tools:含有netstat、ifconfig、route、arp等命令

bash-completion:tab补全功能工具包

tree:tree以树形结构显示文件和目录

htop:系统进程相关信息查看工具

lrzsz:包含上传(rz)下载(sz)文件工具

 [root@centos ~]# yum install -y wget vim net-tools bash-completion tree htop lrzsz

配置国内YUM源及拓展源

[root@centos ~]# cd /etc/yum.repos.d/
[root@centos yum.repos.d]# mkdir bak
[root@centos yum.repos.d]# mv *.repo bak/

新建文件夹将原有repo文件备份

浏览器搜索阿里镜像站,找到CentOS和epel

 下滑找到CentOS-7.repo拉取命令复制运行

 下滑找到epel-7.repo拉取命令复制运行

[root@centos yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@centos yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

测试YUM源是否可用并建立缓存

[root@centos yum.repos.d]# yum repolist

[root@centos yum.repos.d]# yum makecache

快照

建议对配置好基础环境的虚拟机做快照,方便后续使用干净的机器

  • 3
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值