Aside

CentOS Minimal 安装和配置TIPS


同步[GEJOIN.COM]

Linux 各种发行版虽然和Unix系非常相近,但还是有许多差别的。Linux更有趣吧.最近需要学习和测试,就在OSX平台下VirtualBox重新安装CentOS 7.由于机器本身性能原因,另外个人觉得Minimal安装不仅节约资源,而且可以更好的锻炼动手能力。再次把这次安装配置记录下来。

1.安装媒体介质是CentOS-7-x86_64-DVD-1511.iso(4.3GB.)
2.选择Minimal最小化安装。不包含KDE/GOME.
3.安装完成后进行配置,首先网络,试了ifconfig..(minimal不包含net-tools),需要自行安装,选择以CDROM(ISO)为安装源。
挂载光盘镜像:

# mkdir -p /mnt/cdrom
# mount /dev/cdrom  /mnt/cdrom

2.设置源
为了使用光盘镜像安装源,配置yum.repo:
暂时将/etc/yum.repos.d目录下文件备份,新建CentOS-Iso.repo,添加下面内容:
# vi CentOS-Iso.repo

[base]
name=iso
baseurl=file:///mnt/cdrom
gpgcheck=0

3.安装设置网络
# yum install net-tools
虚拟机设置NAT和HOST-ONLY两个网卡,配置静态IP,配置文件:
# vim /etc/sysconfig/network-scripts/ifcfgX

YPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.56.100
NETMASK=255.255.255.0
NETWORK=192.168.56.0
IPV4_FAILURE_FATAL=no
NAME=enp0s3
UUID=ad60e4e1-c250-47f2-a0d2-fa1fbdbb0bd2
DEVICE=enp0s3
ONBOOT=yes

配置好后重启网络,测试内外网是否正常。
# service network restart
4.关闭防火墙,CentOS 7 不是直接设置iptables
# systemctl stop firewalld.service && sudo systemctl disable firewalld.service
5.安装一些必备的软件如wget,php等看个人需要。
6.安装pip
# wget https://bootstrap.pypa.io/get-pip.py
# python get-pip.py

7.设置时区和时间
查看当前时区 date -R
修改设置时区 tzselect
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
或在profile(/etc/bashrc)添加环境变量
TZ='Asia/Shanghai'; export TZ
设置时间更新同步
# yum install -y ntpdate
# ntpdate us.pool.ntp.org
8.设置管理员sudoers
# vim /etc/sudoers 添加:

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
gwang   ALL=(ALL)       ALL

9.其它
终端ssh连接后警告:

-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
[gwang@localhost ~]$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE=UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

修复:

sudo vi /etc/environment

LANG=en_US.utf-8
LC_ALL=en_US.utf-8

10.继续..