CentOS官方于2014年7月7日发布64位CentOS 7.0.1406开始,不知不觉已快半年了。也已经有越来越多的软件开始支持CentOS7了。ITGeeker也尝试将越来越多的服务架构于其之上。
CentOS 7是一个大版本更新,应该有不少提升。连服务的启动停止命令也有了很大的变化。
CentOS 6及之前:
- service httpd restart
CentOS 7:
- systemctl start httpd.service
1. 更新系统并安装必备的组件
- yum upgrade or yum update
- yum install wget telnet perl perl-devel net-tools kernel-devel
- yum groupinstall "Development tools" -y
安装这些之后会大大方便今后安装其他应用是碰到的依赖包问题。其中net-tools是为了提供dig,nslookup,ipconfig等命令,方便配置CentOS 7初始化网络环境。如果不安装这个,在CentOS 7中,可以使用ip addr命令来代替ipconfig进行当前ip地址查询。
2. 添加源(repository)REMI & EPEL yum安装时,要想安装比较新的版本软件,可以试试这两个源。都有一些国内镜像,我添加的EPEL是阿里云镜像的。
这是适合CentOS 6的源
- cd /tmp && wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && wget http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm && rpm -Uvh remi-release-6.rpm epel-release-6-8.noarch.rpm
真正适合CentOS 7的epel和remi源
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
如果国外没法用,那用国内的镜像源
- #中科大镜像源
- rpm -Uvh http://mirrors.ustc.edu.cn/centos/7.0.1406/extras/x86_64/Packages/epel-release-7-5.noarch.rpm
- #浙大源
- rpm -Uvh http://mirrors.zju.edu.cn/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
- #上海交大源
- rpm -Uvh http://ftp.sjtu.edu.cn/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
- #sohu镜像源,更新比较慢
- rpm -Uvh http://mirrors.sohu.com/fedora-epel/7/x86_64/e/epel-release-7-2.noarch.rpm
使用方法:
更换CentOS7的下载源为阿里云:
- #备份
- mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
- #下载源到本地
- wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- #生成缓存
- yum makecache
3. FQDN配置,全称Fully Qualified Domain Name
有些软件,特别是邮件系统对这个要求比较高。
- vi /etc/hosts
- 127.0.0.1 localhost.localdomain localhost geeker
- ::1 localhost.localdomain localhost geeker
- vi /etc/sysconfig/network
- HOSTNAME=geeker
- #设置好之后,查询是否完整
- hostname -f
4. 关闭Selinux
这是Centos系统的安装机制,单单往往导致很多软件无法正常安装,让我们关掉它吧!
- /etc/selinux/config
- #在 SELINUX=enforcing 前面加个#号注释掉它
- #SELINUX=enforcing
- #然后新加一行
- SELINUX=disabled
- #SELINUXTYPE=targeted #注释掉这行
保存,退出,重启系统,搞定。
不想重启,可以使用
- setenforce 0 #使配置立即生效
5. CentOS 7的防火墙关闭和iptables安装
CentOS 7.0默认使用的是firewall作为防火墙,但可能一下子很难适应,让我们先改回原先的iptables防火墙吧!
关闭CentOS 7的firewall:
- systemctl stop firewalld.servic #停止firewall
- systemctl disable firewalld.service #禁止firewall开机启动
安装iptables防火墙
- yum install iptables-services #安装
- vi /etc/sysconfig/iptables #编辑防火墙配置文件
启动iptables防火墙
- systemctl restart iptables.service #最后重启防火墙使配置生效
- systemctl enable iptables.service #设置防火墙开机启动
6. 本地SMTP邮件发送功能(Postfix) 很多软件和服务可以用到这个功能给用户发送通知邮件,需要配置一下。
最好加上一个认证,使用Postfix + Saslauthd
最好用telnet测试一下,前面安装的telnet就发挥作用了。
Tips小技巧: 这里输入引用文本有时候telnet登陆后就退不出来了ctrl+c也不管用此时可以使用ctl+] 切换,然后quit退出。
7. CentOS 7时间同步及更改
和之前基本一样:
- date
- yum install ntpdate -y
- ntpdate time.windows.com && hwclock -w
- #连网更新时间,如果成功,将系统时间,写入BOIS
- hwclock -w 或 hwclock --systohc
- date -s 20150119
- date -s 17:28:00
8. Shell登陆操作显示中文乱码问题(和CentOS 6一样,问题还是存在) 方法一:
然后在/etc/profile文件中增加export LC_ALL=zh_CN.GBK内容。使得全部的LC*都统一了。
重启主机
ITGeeker技术奇客使用的是xshell,直接在当前链接的属性-终端-选择UTF-8为编码即可。如果你经常使用变换使用shell,那就用第一种方法吧。
9. FTP服务安装(vsftpd安装) 为主机开通FTP服务还是非常有必要的,我们为主机快速安装vsftpd吧。
可以参考详细教程 CentOS6.5 64bit如何安装配置FTP服务(vsftpd)
- yum install vsftpd -y
- vi /etc/vsftpd/vsftpd.conf
- #记得CentOS 7启动命令有所不同
- systemctl restart vsftpd
- systemctl enable vsftpd
10. Vmware Tools安装 如果你使用的是虚拟机,那最好装一下Vmware Tools
先点击Vmwar虚拟机管理界面菜单,虚拟机–安装Vmware Tools安装。
- mkdir /mnt/cdrom && mount -t iso9660 /dev/cdrom /mnt/cdrom && cd /mnt/cdrom && cp VMwareTools-9.6.2-1688356.tar.gz /root
- mount -t iso9660 /dev/cdrom /mnt/cdrom && cd /mnt/cdrom && cp VMwareTools-9.6.2-1688356.tar.gz /root
- cd /root && tar zxvf VMwareTools-9.6.2-1688356.tar.gz && cd vmware-tools-distrib
- #安装vmware tools
- ./vmware-install.pl
依赖包,如果有需要 yum -y install perl perl-devel
请使用你的版本代替VMwareTools-9.6.2-1688356.tar.gz