linux第四課

一、配置軟件倉庫
1.yum簡介
基於rpm軟件包的安裝部署機制
自動解決軟件包的依賴關係
需要先配置軟件倉庫
2.配置本地的軟件倉庫
a.放入centos7.iso鏡像文件到光驅中,確保電源開啓
b.命令操作
# umount /dev/cdrom
# ls /mnt
# mount /dev/cdrom /mnt
# ls /mnt
# mkdir -p /repo/cos7dvd
# cp -rf /mnt/ /repo/cos7dvd
# du -sh /repo/cos7dvd /mnt
3.客戶端配置yum文件
# ls /etc/yum.repos.d/
# mkdir /etc/yum.repos.d/oldrepo
# mv /etc/yum.repos.d/.repo /etc/yum.repos.d/oldrepo/
# ls /etc/yum.repos.d/
# yum-config-manager --add file:///repo/cos7dvd/
# ls /etc/yum.repos.d/
# vim /etc/yum.conf
...
8 gpgcheck=0 //把1修改爲0 禁用gpgcheck檢驗
...
4.驗證
# yum clean all 清楚yum緩存
# yum repolist 驗證倉庫名字,路徑,軟件包數量

二、yum管理應用程序
1.查詢軟件包
基本用法
格式:yum list [軟件名] .. ..
eg:
[root@ntd1711 ~]# yum list firefox httpd
2.獲取軟件包的描述信息
基本用法
格式:yum info [軟件名] .. ..
eg:
[root@ntd1711 ~]# yum info httpd
[root@ntd1711 ~]# yum info firefox
3.查詢文件和命令由哪個包生成
基本用法
格式:yum privides "/程序或文件名".. ..
eg:
[root@ntd1711 ~]# yum provides "
/vim" | more

實驗:
a.列出軟件包名稱、版本信息
檢查軟件 httpd、firefox、rar是否已經安裝
[root@ntd1711 ~]# yum list firefox httpd rar
b.查詢軟件包描述信息
瞭解軟件包 kernel、bash的用途
[root@ntd1711 ~]# yum info kernel
[root@ntd1711 ~]# yum info bash
瞭解軟件包 httpd、wireshark的用途
[root@ntd1711 ~]# yum info httpd
[root@ntd1711 ~]# yum info wireshark
c.查詢哪些軟件包能提供指定的程序/文件
查詢命令程序vim由哪個軟件包提供
[root@ntd1711 ~]# which vim
/usr/bin/vim
[root@ntd1711 ~]# yum provides /usr/bin/vim
查詢文件/etc/redhat-release由哪個軟件包提供
[root@ntd1711 ~]# yum provides /etc/redhat-release

4.安裝/卸載應用軟件
安裝:
基本用法
格式:yum [-y] install 軟件名 .. ..
eg:
[root@ntd1711 ~]# yum list httpd
[root@ntd1711 ~]# yum -y install httpd
[root@ntd1711 ~]# yum list httpd
刪除:
基本用法
格式:yum [-y] remove 軟件名 .. ..
eg:
[root@ntd1711 ~]# yum list httpd
[root@ntd1711 ~]# yum -y remove httpd
[root@ntd1711 ~]# yum list httpd
重新安裝:
基本用法
格式:yum [-y] reinstall 軟件名 .. ..
eg:
[root@ntd1711 ~]# vim /etc/passwd
[root@ntd1711 ~]# which vim
[root@ntd1711 ~]# rm -rf /usr/bin/vim
[root@ntd1711 ~]# vim /etc/passwd
[root@ntd1711 ~]# yum provides /usr/bin/vim
[root@ntd1711 ~]# yum list vim-enhanced
[root@ntd1711 ~]# yum -y reinstall vim-enhanced
[root@ntd1711 ~]# vim /etc/passwd

三、快速部署Web
1.Web服務概述
Web服務器是一種基於B/S架構的網頁資源通信
B 瀏覽器
S 服務器

網頁:以html,htm,jsp,php,asp...等結尾的文件
網站:多個網頁的集合

程序員(Dev):開發網頁/網站(java,.net,Python,php)

測試工程師(QA)

運維工程師(OP):上線(託管到服務器)
職責:
安裝Linux服務器
配置Web服務器
把程序員寫的網站部署到web服務器
測試

2.快速搭建Web服務器站點
a.安裝軟件包
[root@ntd1711 ~]# yum repolist
[root@ntd1711 ~]# yum list httpd
[root@ntd1711 ~]# yum -y install httpd
[root@ntd1711 ~]# yum list httpd
b.新建缺省主頁
[root@ntd1711 ~]# vim /var/www/html/index.html
This is a test Page!!!
[root@ntd1711 ~]# cat /var/www/html/index.html
This is a test Page!!!
c.啓動服務
[root@ntd1711 ~]# systemctl start httpd //啓動httpd服務
[root@ntd1711 ~]# systemctl enable httpd //設置httpd開機自啓動
d.測試
[root@ntd1711 ~]# firefox http://127.0.0.1/index.html 其實訪問的是服務器上面的/var/www/html/index.html

提問:
[root@ntd1711 ~]# mkdir /var/www/html/day04/
[root@ntd1711 ~]# vim /var/www/html/day04/test01.html
Test Page!!!
[root@ntd1711 ~]# cat /var/www/html/day04/test01.html
Test Page!!!
在瀏覽器上輸入什麼內容可以訪問test01.html???

A:http://127.0.0.1/var/www/html/day04/test01.html
B:http://127.0.0.1
C:http://127.0.0.1/test01.html
D:http://127.0.0.1/day04/test01.html

四、快速部署Ftp
1.FTP服務概述
基於C/S架構
C 客戶端
S 服務器
文件上傳/下載服務
2.ftp賬戶
匿名用戶:默認訪問的是/var/ftp
本地用戶:默認訪問的是/home/xxx
3.快速搭建FTP服務器站點
a.安裝軟件包
[root@ntd1711 ~]# yum repolist
[root@ntd1711 ~]# yum list vsftpd
[root@ntd1711 ~]# yum -y install vsftpd
[root@ntd1711 ~]# yum list vsftpd
b.修改主配置文件
[root@ntd1711 ~]# useradd vip2018
[root@ntd1711 ~]# passwd vip2018
c.啓動服務器
[root@ntd1711 ~]# systemctl start vsftpd
[root@ntd1711 ~]# systemctl enable vsftpd
d.測試
[root@ntd1711 ~]# firefox ftp://127.0.0.1 //默認登錄的是/var/ftp
[root@ntd1711 ~]# firefox ftp://[email protected] //登錄到/home/vip2018

補充:
Windows真實機連接Linux服務器
要想實現這個功能需要具備什麼條件?
1.Windows真實機與Linux服務器之間可以通信
2.Linux服務器上面需要配置遠程登錄服務(ssh)
3.需要提供Linux服務器上面的授權賬戶和密碼

a.設置vmware虛擬機的網卡爲vmnet1
b.設置win的vmnet1的ip爲自動獲取方式(192.168.199.1)
c.設置Linux的ip爲192.168.199.0/24
[root@ntd1711 ~]# nmcli connection modify eno16777736 ipv4.method manual ipv4.addresses 192.168.199.2/24
[root@ntd1711 ~]# nmcli connection down eno16777736
[root@ntd1711 ~]# nmcli connection up eno16777736
[root@ntd1711 ~]# ifconfig
d.在windows下ping linux確保可以ping通
開始/運行/cmd
ping 192.168.199.2

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章