写在前面的话

1.本文参考了[蓝狐的博客](http://www.bluefoxah.org/ "蓝狐的博客")中[《新版Teamtalk部署教程》](http://www.bluefoxah.org/teamtalk/new_tt_deploy.html "《新版Teamtalk部署教程》")中的部分内容。

2.本文配置中使用的是腾讯云的虚拟机


日常初始化Centos主机,主要的思路和流程是修改源、卸载非必要的软件、安装常用软件、系统升级、*配置lnmp(选配)、安全配置(后面再写)。

修改源

个人比较推荐的源有两个,一个是[大连东软学院的开源镜像站](http://mirrors.neusoft.edu.cn/ "大连东软学院的开源镜像站"),另外一个是[清华大学开源软件镜像站](https://mirror.tuna.tsinghua.edu.cn/ "清华大学开源软件镜像站"),因为在我这这两个源的速度很快,但具体的还是要测一下,优先选择速度最快的源。介于使用的是腾讯云,在此就不修改,只贴出流程。

备份并编辑源文件

shell

sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
 vim /etc/yum.repos.d/CentOS-Base.repo

修改源信息

东软源,注意,大连东软学院的开源镜像站的修改步骤是之2、3,即不需要执行1命令,直接执行该条命令,后在执行3命令即可。

shell

 sed -e "s/^mirrorlist/#mirrorlist/g" -e"s/#baseurl/baseurl/g" -e "s/mirror\.centos\.org/mirrors.neusoft.edu.cn/g" -i /etc/yum.repos.d/CentOS-Base.repo

清华大学开源软件镜像站

 # CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-$releasever - Base

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates

[updates]

name=CentOS-$releasever - Updates

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

163源,查看帮助,可以直接下载对应版本的repo文件

http://mirrors.163.com/.help/centos.html

科大源,可下载repo文件,也可以直接编辑

https://lug.ustc.edu.cn/wiki/mirrors/help/centos

# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client.  You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-$releasever - Base

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

#released updates

[updates]

name=CentOS-$releasever - Updates

# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

baseurl=http://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

搜狐源, 同163源,可直接下载repo文件

http://mirrors.sohu.com/help/centos.html

执行更新命令

sudo yum makecache

卸载非必要的软件

卸载这些软件,主要为后面安装lnmp减少一些不必要的麻烦

 yum -y remove httpd* php* mysql-server mysql mysql-libs php-mysq

安装常用软件

yum -y install wget vim git texinfo patch make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils screen

系统升级

sudo yum -y update