linux實訓第一天--Centos7基礎配置(ip,本地yum源,yum安裝httpd,配置虛擬主機)
案例一
1.0配置ip為192.168.147.20/24
1.1配置Yum
1.2設定主機名為svr.tedu.cn
1.3安裝httpd軟體
案例1.0-->配置IP
[[email protected] ~]#nmcli connection modify ens33 ipv4.method manual ipv4.addresses
192.168.147.2.20/24 connection.autoconnect yes ##紅色為網絡卡名,藍色為ip地址。根據實際情況修改
[[email protected] ~]#nmcli connection up ens33 ##啟動網絡卡
注意:有的可能不是ens33 這時可以ifconfig進行檢視即可
##出現seccessfuly即可
案例1.1-->配置本地yum
[[email protected]
~]#mkdir /mnt/cdrom[[email protected] ~]#mount /dev/cdrom /mnt/cdrom //掛載光碟
[[email protected] ~]#rm -rf /etc/yum.repos.d/*.repo
[[email protected]
~]#vim /etc/yum.repos.d/Redhat.repo !!注意一點是以”.repo”結尾[Redhat] //倉庫標識
name=This is Rehat.iso //描述資訊
baseurl=/mnt/cdrom //路徑
enabled=1 //開機自啟動
gpgcheck=0 //是否檢測資訊
[[email protected] ~]yum repolist
案例1.3-->設定主機名
[[email protected] ~]#echo svr7.tedu.cn > /etc/hostname //永久配置
案例1.4-->下載httpd軟體包
[[email protected] ~]#yum -y install httpd
- 案例二-->yum軟體包以及趣玩額外rpm
下載tools.tar.gz
boxes格式:
[[email protected]~]#echo “This is a test ” | boxes -d “dog”
Oneko格式:
[[email protected]~]#oneko -fg green -speed 10
sl格式:
[[email protected]~]#sl
- 案例三-->搭建httpd服務
[[email protected] ~]#yum -y install httpd
[[email protected] ~]#echo test > /var/www/html/index.html
[[email protected] ~]#systemctl restart httpd
[[email protected] ~]#firefox http://127.0.0.1
- 案例四:搭建基於域名的web主機
[[email protected] ~]#vim /etc/hosts //設定對映ip
127.0.0.1 www.a.com
127.0.0.1 www.b.com
[[email protected] ~]#vim /etc/httpd/conf.d/httpd.conf
<VirtualHost *:80> //*指ip,80為埠
ServerName www.a.com //域名
DmentRoot /var/www/html //網頁目錄檔案
</VirtualHost>
<VirtualHost *:80>
ServerName www.b.com
DmentRoot /var/www/private
</VirtualHost>
[[email protected] ~]#mkdir /var/www/private | echo private1 > /var/www/html/index.html
[[email protected] ~]#echo html1 > /var/www/html/index.html
[[email protected] ~]#systemctl restart httpd
[[email protected] ~]#firefox www.a.com
[[email protected] ~]#firefox www.b.com
補充:
常見的linux目錄的作用
/ linux系統的開始
/etc 配置檔案
/boot 引導檔案
/var 容易變化的檔案
##考慮是否裝圖形介面時,注意在此時的配置。GUI則是帶圖形介面的作業系統。