一、CentOS7.4下載
1、進入CentOS下載官網,找到CentOS7.4版本

2、在CentOS7.4版本頁面中,找到isos/

3、進入頁面後,可以看到x86_64

4、在CentOS下載頁面中,選擇 CentOS-7-x86_64-DVD-1708.torrent進行下載

5、下載完成之後,由於“CentOS-7-x86_64-DVD-1708.torrent”只是一個BT種子檔案,而且非常小,這就需要我們使用迅雷等工具來對源映象進行下載了
(1)開啟迅雷,新建任務,把“CentOS-7-x86_64-DVD-1708.torrent”BT種子檔案拖入到新建任務中,並點選立即下載

(2)下載完成之後會生成如下的幾個檔案,CentOS-7-x86_64-DVD-1708.iso就是我們在工作中使用的映象了

二、CentOS7.4安裝
1、開啟你的VMware Workstation Pro,並點選“建立新的虛擬機器”,沒有安裝VMware Workstation Pro請點選VMware Workstation 14下載與安裝

2、點選典型(推薦)(T),並點選“下一步”

3、點選稍後安裝作業系統(S),並點選“下一步”

4、點選Linux(L),因為我們之前下載的 CentOS-7-x86_64-DVD-1708.iso 是64位 7.4版本的,所以這裡我們選擇CentOS 7 64位,並點選“下一步”

5、虛擬機器名稱可以更改也可以不更改看自己需求,修改虛擬機器的安裝路徑,並點選“下一步”

6、磁碟選擇預設為20.0GB,點選將虛擬磁碟儲存為單個檔案(O),並點選“下一步”

7、點選“完成”

8、點選“編輯虛擬機器設定”

9、點選“使用ISO映像檔案(M)”,並新增我們之前下載好的CentOS-7-x86_64-DVD-1708.iso

10、預設為NAT 模式(N):用於共享主機的IP地址即可

提示:11-13步驟 移除USB控制器、音效卡和印表機 只是為了騰出更多的資源空間 (可以選擇跳過 不移除)
11、選擇USB 控制器,並點選“移除(R)”

12、選擇音效卡,並點選“移除(R)”

13、選擇印表機,並點選“移除(R)”,最後點選“確定”

14、點選“開啟此虛擬機器”

15、正在開啟虛擬機器,滑鼠移入到虛擬機器中,並按下“↑”鍵,選擇Install CentOS 7,最後按下“Enter 鍵”
提示: 滑鼠移動到虛擬機器內部單擊或者按下Ctrl + G,滑鼠即可移入到虛擬機器中
按下Ctrl + Alt,滑鼠即可移出虛擬機器
注意: 在虛擬機器中的操作,滑鼠必須要移入到虛擬機器中,否則虛擬機器感應不到,無法對其進行操作

16、按下“Enter 鍵”


17、預設安裝過程中的安裝介面使用English (英語),點選“Continue”

18、配置時區 (DATE & TIME)
(1)選擇DATE & TIME

(2)時區設定為 Region:Asia City:Shanghai
日期和時間 設定與自己的電腦時間同步,最後點選“Done”

19、設定軟體選擇 (SOFTWARE SELECTION)
(1)選擇SOFTWARE SELECTION

(2)點選勾選 Compatibility Libraries 和 Development Tools

如果希望安裝帶有介面的CentOS,請在左邊Base Environment中,選擇Server with GUI(帶圖形使用者介面的伺服器),預設為Minimal Install (最小安裝),提示:如果安裝有介面版本的,在如下的第22步驟中的操作會有所不同 (安裝有介面版本的其實用處不大,都是可以通過命令列來設定的),這裡我沒有安裝有介面版本的

20、設定安裝位置 (INSTALLATION DESTINATION)
(1)選擇INSTALLATION DESTINATION

(2)點選 I will configuire parttioning,然後再點選“Done”

(3)更改模式,標準分割槽Standard Partition,點選“+”按鈕新增分割槽

(4)新增 /boot分割槽,大小300MB,Add mount point


(5)新增 swap分割槽,一般情況是實體記憶體的2倍大小,用於實體記憶體不足時使用,但可能造成系統不穩定,所以看情況,可以設定小一點,甚至設定為0MB,這裡我設定為512MB,Add mount point


(6)增加根分割槽,不填寫大小,即預設剩餘的空間都給根分割槽,Add mount point


(7)點選“Done”

(8)點選“Accept Changes”

21、點選“Begin Installation”,開始安裝

22、設定系統使用者root的密碼 (ROOT PASSWORD)
(1)選擇ROOT PASSWORD

(2)為root設定密碼 (密碼長度最好不要小於6位數),然後點選“Done”

23、等待安裝完成,然後點選“Reboot”

三、CentOS7.4基本設定
1、登入CentOS,預設賬號為root,密碼為 你在前面安裝時設定的root密碼
提示:在輸入密碼時,linux為了安全起見,是看不到你輸入的密碼。同時,如果是使用的是鍵盤右邊的數字鍵盤輸入密碼的話,建議檢視一下,數字鍵盤是否開啟 (建議使用字母按鍵上面一排的 數字鍵輸入密碼)

2、配置IP地址,閘道器
cd /etc/sysconfig/network-scripts/ //進入到network-scripts目錄下
vi ifcfg-ens32 //編輯配置檔案
//修改以下內容
BOOTPROTO=static //啟用靜態IP地址
ONBOOT=yes //開啟自動啟用網路連線
//新增以下內容
IPADDR=192.168.30.1 //設定IP地址
NETMASK=255.255.255.0 //子網掩碼
GATEWAY=192.168.131.2 //設定閘道器


2.1、如何設定Linux的IP地址
1、在本地電腦開啟“命令列視窗”,輸入命令ipconfig,檢視 乙太網介面卡 VMware Network Adapter VMnet8下的IPv4 地址
2、可以看到 乙太網介面卡 VMware Network Adapter VMnet8下的IPv4 地址為 192.168.30.2
3、當我們設定Linux的IP地址時,需要保證Linux的IP地址 與 VMnet8下的IPv4地址 的前面三位數必須相同,即 192.168.30 必須相同,這樣Linux就能跟我們本地電腦互相通訊,最後一位數不相同即可,例如Linux的IP地址可以設定為192.168.30.1 或者 192.168.30.124等

2.2、如何設定Linux的閘道器:
1、點選編輯(E) → 虛擬網路編輯器(N)

2.3、如何設定Linux的閘道器,選擇VMnet8,再點選"NAT設定"按鈕,檢視VMnet8 (NAT 模式)下的子網掩碼


3、檢視VMnet8 (NAT 模式)下的閘道器,選擇VMnet8,再點選"NAT設定"按鈕

3、重啟網路服務
service network restart

4、設定DNS地址
vi /etc/resolv.conf //編輯 resolv.conf檔案
nameserver 114.114.114.114 //新增DNS地址
可以新增多個DNS地址,格式為:
nameserver xxx1.xxx1.xxx1.xxx1
nameserver xxx2.xxx2.xxx2.xxx2
常用的DNS地址:
阿里 223.5.5.5 或者 223.6.6.6
谷歌 8.8.8.8
國內移動、電信和聯通通用的DNS 114.114.114.114

提示:如果是內網,配置上面的DNS地址有可能是訪問不了外網的,在電腦右下角的網路圖示中滑鼠右鍵,選擇開啟"網路和Internet"設定,選擇WLAN,然後在點選你連線的網路,檢視網路資訊

填寫內網的IPv4 DNS 伺服器地址即可

5、檢視是否能夠訪問外網
ping -c3 www.baidu.com
PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=128 time=9.45 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=128 time=12.2 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=128 time=9.29 ms
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 9.296/10.346/12.293/1.388 ms

6、永久關閉 firewalld防火牆(centos7預設的防火牆是firewalld防火牆,不是使用iptables,因此需要關閉firewalld服務)
systemctl stop firewalld.service // 停止firewalld服務
systemctl disable firewalld.service // 開機禁用firewalld服務
iptables -L //列出所有iptables規則

7、永久關閉SELinux防火牆
vi /etc/sysconfig/selinux //編輯selinux檔案
SELINUX=disabled //把檔案中的SELINUX=enforcing 改成 SELINUX=disabled 即可
sestatus //檢視SELinux狀態

獲取當前selinux防火牆的安全策略
sestatus
可以看到當前selinux防火牆的安全策略仍為enforcing,配置檔案並未生效

這時需要我們重啟,再去檢視SELinux防火牆的狀態,可以看到已經關閉了

8、給/etc/rc.d/rc.local 檔案設定 “x”可執行許可權,最初設定預設是沒有可執行許可權的
chmod +x /etc/rc.d/rc.local //設定可執行許可權
//設定前
-rwxr-xr--. 1 root root 473 Aug 5 2017 rc.local
//設定後
-rwxr-xr-x. 1 root root 473 Aug 5 2017 rc.local

9、輸入“halt”,關閉虛擬機器,並拍攝快照,儲存當前配置

