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