1.修改主机名

可以使用vi /etc/hosts命令进行修改,在文件里添加一行,加上本机的IP与主机名的绑定(重启机器后生效).

2.配置静态ip地址

先使用ifconfig -a查看一下; 然后在/etc/sysconfig/network-scripts目录下找到名为ens32的网卡,用vi /etc/sysconfig/network-scripts/ifcfg-ens32打开文件并修改。

保存,退出,然后

/etc/init.d/network restart      #重启网卡
3.关闭、禁用centos7默认防火墙

CentOS 7.0默认使用的是firewall作为防火墙,现在把firewall关闭并禁用(禁止开机启动)。

systemctl status firewalld.service           #查看firewall状态
systemctl stop firewalld.service             #关闭firewall
systemctl list-unit-files |grep firewalld    #查看firewalld是否开机自动启动,若显示enabled为开机自启,显示disable为开机不自启
systemctl disable firewalld.service       #禁止开机自启
4.关闭selinux

需要修改/etc/selinux/config的文件,把enforcing改成disabled即可(重启后生效)。或者使用命令

sed -i 7s/enforcing/disabled/  /etc/selinux/config     # 把/etc/selinux/config文件下第7行的enforcing改成disabled

5.更换yum源

centos7默认的源的网址mirrorlist.centos.org,属于国外的网站,可能出现连不上或者网速很慢,反正我用yum安装软件的时候感觉比较慢,所以打算换成国内163网易的yum源。

cd /etc/yum.repos.d               # 切换到yum仓库目录下
mv CentOS-Base.repo CentOS-Base.repo.bak       # 把原来的源重命名备份
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo    #下载163源
mv CentOS7-Base-163.repo CentOS-Base.repo     #更改网易的源为默认的系统yum源
yum  makecache    #生成缓存,将服务器上的软件包信息在本地缓存,提高搜索安装软件的速度
6.关闭系统邮件提示
  • 在终端操作界面总是出现You have new mail in /var/spool/mail/root提示,如果想关闭提示,可以在/etc/profile文件里设置。
echo "unset MAILCHECK">> /etc/profile
source /etc/profile