Vim yum.sh # #建立脚本文件
*!/bin/bash
################ #creat local yum source############
Mkdir/westos # #建立挂载点
Mount/iso/rhel-server-7.0-x86_64-dvd.iso/westos # #将镜像文件挂哉在建立文件案目录剧下
Mkdir/backup
mv/etc/yum.repos.d/*/backup # #将干扰文件放在其他新建的目录下
Cat >/etc/yum.repos.d/yum.repo << End # # Edit Yum.repo
[Test]
Name=test
Baseurl=file:///westos
Gpgcheck=0
End
Yum Clean All # #刷新仓库配置################### #install Share server##########
Yum Intall httpd-y # #安装http
Systemctl Start httpd # #开启http指令
Systemctl Enable httpd
Systemctl Disable FIREWALLD # #表示开机就关闭防火墙
Systemctl Stop Firewalld
################## #mount ISO to share directory##########
Umount Westos # #弹出westos挂载点
mkdir/var/www/html/rehl7.0 # #新建在共享文当下的目录
mount/iso/rhel-server-7.0-x86_64-dvd.iso/var/www/html/rhel7.0 # #重新挂载
echo "/iso/rhel-server-7.0-x86_64-dvd.iso/var/www/html/rhel7.0 iso9660 ro 0 0" >>
/etc/fstab # #mount为临时挂载, to change the mount to permanent the configuration file needs to be changed (>> Plus additional content)
############### #cofig Local yum##############
Rm-fr/etc/yum.repos.d/yum.repo
Cat >/etc/yum.repos.d/yum.repo << End # #重新编辑yum. repo file
[Test]
Name=test
baseurl=file:///var/www/html/rhel7.0 # #路径改变
Gpgcheck=0
End
A script to create a yum shared directory is written, and you can see the shared directory by typing the address on the browser.
You should be aware of two ways to write URLs on your browser
: file:///var/www/html/rhel7.0 (the root of the machine is represented by the third/number)
: http://172.25.39.172 (IP of the Access host)/rhel7.0 (IP back/number indicates the root directory of Apache)
This article from "11897256" blog, declined reprint!
Establishment of Yum repository under Linux system and establishment of directory sharing (script file)