Centos 7.0安装就不说了,跟红帽一样。我选的是Server with GUI,有图形界面好操作些。
一、装完之后,先设网络,修改主机名域名。
CentOS的网卡配置文件在 /etc/sysconfig/network-scripts/目录下,
看到eth0的那个吗,就是我机器上的,你的机器也许名字会不一样,总之就是改这个文件。要是dhcp就改两行,BOOTPROTO=dhcp和ONBOOT=yes. 如果配固定IP,就把dhcp那行注释掉,添加上IP地址等参数。
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
#BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=aa31ca65-336b-4d0a-b6fc-efcce0ae68fb
DEVICE=eth0
ONBOOT=yes
IPADDR=XX.XXX.XXX.XX
PREFIX=XX
GATEWAY=XX.XXX.XXX.XX
DNS1=8.8.8.8
IPV6_PRIVACY=no
二、locale问题
反正我总是碰到locale的问题,装ubuntu和centos都碰到。
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
修改 /etc/environment文件,增加:
LANG=en_GB.utf-8
LC_ALL=en_GB.utf-8
当然你可以用en_US.utf-8。
三、关闭系统防火墙,安装UFW。我比较习惯用UFW,不需要的话就跳过。
systemctl stop firewalld
systemctl status firewalld
systemctl disable firewalld
两种方法安装,一种是通过EPEL repository安装:
yum install -y epel-release
yum install -y ufw
[root@gen~]# systemctl enable ufw
Created symlink from /etc/systemd/system/basic.target.wants/ufw.service to /usr/lib/systemd/system/ufw.service.
另一种方式是下载安装UFW,现在是0.36版本:
wget https://launchpad.net/ufw/0.36/0.36/+download/ufw-0.36.tar.gz
tar xzvf ufw-0.36.tar.gz
cd ufw-0.36/
python setup.py install
装完之后,先允许ssh,免得不小心断掉,然后再enable 防火墙,根据服务来开放端口。
ufw allow 22
ufw default deny incoming
ufw default allow outgoing
ufw status
ufw enable
ufw status
一般我还会改一下SELinux,把enforcing改成permissive或disable随意。
vim /etc/sysconfig/selinux
四、安装时钟同步
yum install ntp
systemctl enable ntpd.service
systemctl start ntpd.service
五、创建用户修改密码,并加入超级用户群组(随你设置_)
[root@genieas01 network-scripts]# adduser user1
[root@genieas01 network-scripts]# passwd user1
Changing password for user user1.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@genieas01 network-scripts]# gpasswd -a user1 wheel
Adding user user1 to group wheel
六、再加一项,检查一下时区对不对,不对就改下。我这是london,但是显示安装的时候是New_York:
[axing@syslog-http ~]$ date
Thu 7 Feb 04:05:35 EST 2019
[root@syslog-http zoneinfo]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 38 Feb 5 18:53 /etc/localtime -> ../usr/share/zoneinfo/America/New_York
[axing@syslog-http ~]$ timedatectl
Local time: Thu 2019-02-07 04:05:42 EST
Universal time: Thu 2019-02-07 09:05:42 UTC
RTC time: Thu 2019-02-07 09:05:42
Time zone: America/New_York (EST, -0500)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2018-11-04 01:59:59 EDT
Sun 2018-11-04 01:00:00 EST
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2019-03-10 01:59:59 EST
Sun 2019-03-10 03:00:00 EDT
查找自己时区的代码可以使用:
[root@syslog-http zoneinfo]# timedatectl list-timezones | grep Europe
Europe/Amsterdam
Europe/Andorra
Europe/Astrakhan
Europe/Athens
Europe/Belgrade
Europe/Berlin
Europe/Bratislava
Europe/Brussels
Europe/Bucharest
Europe/Budapest
Europe/Busingen
Europe/Chisinau
Europe/Copenhagen
Europe/Dublin
Europe/Gibraltar
Europe/Guernsey
Europe/Helsinki
Europe/Isle_of_Man
Europe/Istanbul
Europe/Jersey
Europe/Kaliningrad
Europe/Kiev
Europe/Kirov
Europe/Lisbon
Europe/Ljubljana
Europe/London
Europe/Luxembourg
Europe/Madrid
Europe/Malta
Europe/Mariehamn
Europe/Minsk
Europe/Monaco
Europe/Moscow
Europe/Oslo
Europe/Paris
Europe/Podgorica
Europe/Prague
Europe/Riga
Europe/Rome
Europe/Samara
Europe/San_Marino
Europe/Sarajevo
Europe/Saratov
Europe/Simferopol
Europe/Skopje
Europe/Sofia
Europe/Stockholm
Europe/Tallinn
Europe/Tirane
Europe/Ulyanovsk
Europe/Uzhgorod
Europe/Vaduz
Europe/Vatican
Europe/Vienna
Europe/Vilnius
Europe/Volgograd
Europe/Warsaw
Europe/Zagreb
Europe/Zaporozhye
Europe/Zurich
#或者tzselect 命令,但tzselect只是帮我们把选择的时区显示出来,并不会实际生效,只是告诉我们怎么样去设置环境
[root@syslog-http ~]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 8
Please select a country.
1) Albania 18) Guernsey 35) Poland
2) Andorra 19) Hungary 36) Portugal
3) Austria 20) Ireland 37) Romania
4) Belarus 21) Isle of Man 38) Russia
5) Belgium 22) Italy 39) San Marino
6) Bosnia & Herzegovina 23) Jersey 40) Serbia
7) Britain (UK) 24) Latvia 41) Slovakia
8) Bulgaria 25) Liechtenstein 42) Slovenia
9) Croatia 26) Lithuania 43) Spain
10) Czech Republic 27) Luxembourg 44) Sweden
11) Denmark 28) Macedonia 45) Switzerland
12) Estonia 29) Malta 46) Turkey
13) Finland 30) Moldova 47) Ukraine
14) France 31) Monaco 48) Vatican City
15) Germany 32) Montenegro 49) Åland Islands
16) Gibraltar 33) Netherlands
17) Greece 34) Norway
#? 7
The following information has been given:
Britain (UK)
实际修改时区要用timedatectl 命令:
[root@syslog-centos axing]# timedatectl set-timezone Europe/London
[root@syslog-centos axing]# date
Thu 7 Feb 09:14:34 GMT 2019
[root@syslog-centos axing]# timedatectl set-local-rtc 1
#将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间