CentOS官方于2014年7月7日发布64位CentOS 7.0.1406开始,不知不觉已快半年了。也已经有愈来愈多的软件开始支持CentOS7了。ITGeeker也尝试将愈来愈多的服务架构于其之上。php
CentOS 7是一个大版本更新,应该有很多提高。连服务的启动中止命令也有了很大的变化。mysql
CentOS 6及以前:linux
service httpd restart
CentOS 7:sql
systemctl start httpd.service
1. 更新系统并安装必备的组件shell
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地址查询。windows
2. 添加源(repository)REMI & EPEL yum安装时,要想安装比较新的版本软件,能够试试这两个源。都有一些国内镜像,我添加的EPEL是阿里云镜像的。centos
这是适合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
使用方法:
yum --enablerepo=remi install php mysql php-mysql mysql-server phpmyadmin #或者 yum --enablerepo=epel install php mysql php-mysql mysql-server phpmyadmin
更换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
yum remove sendmail #若是有原先的sendmail,先移除 yum install postfix vi /etc/postfix/main.cf #编辑postfix主配置文件 useradd itgeeker #增长用户 passwd itgeeker #设置用户密码 yum install cyrus-sasl* /bin/systemctl restart saslauthd.service && /bin/systemctl restart postfix.service #启动postfix和saslauth服务
最好用telnet测试一下,前面安装的telnet就发挥做用了。
telnet localhost smtp ehlo localhost mail from: rcpt to:<alanljj@qq.com> data Welcome to itgeeker mail server . quit #查看邮件内容 less /var/log/maillog cd /root/Maildir/new #注意M要大写 ll cat ***** #*表明列出的文件名,能够查看新的邮件内容 vi /var/log/maillog
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同样,问题仍是存在) 方法一:
vi /etc/sysconfig/i18n 文件中修改LANG的设置为: #LANG="en_US.UTF-8" #SYSFONT="latarcyrheb-sun16" LANG="zh_CN.GBK" LANGUAGE="zh_CN.GBK:zh_CN.GB18030:zh_CN.GB2312:zh_CN" SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en" SYSFONT="lat0-sun16"
而后在/etc/profile文件中增长export LC_ALL=zh_CN.GBK内容。使得所有的LC*都统一了。
重启主机
方法二: 更改shell的显示语言
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