Linux服务器yum源配置(CentOS 7)
- 利用工具把我们的iso包传到服务器上(我这里传到了root下)
- 我们要通过磁盘挂载的方式把iso文件挂载到我们的服务器上
--在root下先创建一个文件夹用来挂载ISO文件(通常我们挂载到/mnt/目录下) [root@yanshi ~]# mkdir CentOS --把我们的ISO文件挂载到CentOS目录下 [root@yanshi ~]# mount -o loop /root/CentOS-7-x86_64-DVD-1810.iso /root/CentOS/ mount: /dev/loop0 is write-protected, mounting read-only --进入/etc/yum.repos.d目录 [root@yanshi ~]# cd /etc/yum.repos.d/ --删除该目录下所有文件 [root@yanshi yum.repos.d]# rm -rf * --创建serveryum.repo文件 [root@yanshi yum.repos.d]# vi /etc/yum.repos.d/serveryum.repo --输入下面内容 [server] name=server baseurl=file:///root/CentOS enabled=1 gpgcheck=0 --清除yum缓存 [root@yanshi yum.repos.d]# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: server Cleaning up list of fastest mirrors Other repos take up 454 M of disk space (use --verbose for details) --重建yum [root@yanshi yum.repos.d]# yum makecache Loaded plugins: fastestmirror, langpacks Determining fastest mirrors server | 3.6 kB 00:00:00 (1/4): server/group_gz | 166 kB 00:00:00 (2/4): server/primary_db | 3.1 MB 00:00:00 (3/4): server/filelists_db | 3.2 MB 00:00:00 (4/4): server/other_db | 1.3 MB 00:00:00 --安装httpd用来配置yum地址 [root@yanshi yum.repos.d]# yum install -y httpd Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-88.el7.centos will be installed --> Processing Dependency: httpd-tools = 2.4.6-88.el7.centos for package: httpd-2.4.6-88.el7.centos.x86_64 --> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-88.el7.centos.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-88.el7.centos.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed ---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed ---> Package httpd-tools.x86_64 0:2.4.6-88.el7.centos will be installed ---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================== Installing: httpd x86_64 2.4.6-88.el7.centos server 2.7 M Installing for dependencies: apr x86_64 1.4.8-3.el7_4.1 server 103 k apr-util x86_64 1.5.2-6.el7 server 92 k httpd-tools x86_64 2.4.6-88.el7.centos server 90 k mailcap noarch 2.1.41-2.el7 server 31 k Transaction Summary ======================================================================================================================================================== Install 1 Package (+4 Dependent packages) Total download size: 3.0 M Installed size: 10 M Is this ok [y/d/N]: y Downloading packages: -------------------------------------------------------------------------------------------------------------------------------------------------------- Total 61 MB/s | 3.0 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : apr-1.4.8-3.el7_4.1.x86_64 1/5 Installing : apr-util-1.5.2-6.el7.x86_64 2/5 Installing : httpd-tools-2.4.6-88.el7.centos.x86_64 3/5 Installing : mailcap-2.1.41-2.el7.noarch 4/5 Installing : httpd-2.4.6-88.el7.centos.x86_64 5/5 Verifying : httpd-tools-2.4.6-88.el7.centos.x86_64 1/5 Verifying : apr-1.4.8-3.el7_4.1.x86_64 2/5 Verifying : mailcap-2.1.41-2.el7.noarch 3/5 Verifying : httpd-2.4.6-88.el7.centos.x86_64 4/5 Verifying : apr-util-1.5.2-6.el7.x86_64 5/5 Installed: httpd.x86_64 0:2.4.6-88.el7.centos Dependency Installed: apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-88.el7.centos mailcap.noarch 0:2.1.41-2.el7 Complete! --拷贝/root/CentOS/目录到/var/www/html/目录下 [root@yanshi ~]# cp -rf /root/CentOS/ /var/www/html/ --配置httpd.conf文件 [root@yanshi ~]# vi /etc/httpd/conf/httpd.conf --输入 /Listen 查找到下面的内容,把最后一行的端口改成不被占用的 # # Listen: Allows you to bind Apache to specific IP addresses and/or # ports, instead of the default. See also the <VirtualHost> # directive. # # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses. # #Listen 12.34.56.78:80 Listen 80 --输入 /ServerName 查找到下面的内容,把最后一行的改成服务器的IP与我们上面修改的端口 # # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn't have a registered DNS name, enter its IP address here. # ServerName 192.168.31.128:80 --关闭httpd服务 [root@yanshi ~]# systemctl enable httpd Authorization not available. Check if polkit service is running or see debug message for more information. Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. --打开httpd服务使配置文件生效 [root@yanshi ~]# systemctl restart httpd Authorization not available. Check if polkit service is running or see debug message for more information. Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details. You have new mail in /var/spool/mail/root --再次修改yum文件 [root@yanshi ~]# vi /etc/yum.repos.d/serveryum.repo --把baseurl改为 =》 http://192.168.31.128:80/CentOS baseurl=http://192.168.31.128:80/CentOS --再次清除yum缓存 [root@yanshi yum.repos.d]# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: server Cleaning up list of fastest mirrors Other repos take up 454 M of disk space (use --verbose for details) --再次重建yum [root@yanshi yum.repos.d]# yum makecache Loaded plugins: fastestmirror, langpacks Determining fastest mirrors server | 3.6 kB 00:00:00 (1/4): server/group_gz | 166 kB 00:00:00 (2/4): server/filelists_db | 3.2 MB 00:00:00 (3/4): server/primary_db | 3.1 MB 00:00:00 (4/4): server/other_db | 1.3 MB 00:00:00 Metadata Cache Created
- 现在我们可以把/root/下的iSO包与挂载的/root/CentOS/目录删掉了
[root@yanshi ~]# cd /root/ [root@yanshi ~]# ll total 4481024 drwxr-xr-x. 2 root root 6 Apr 27 22:52 CentOS -rwxr-xr-x. 1 root root 4588568576 Apr 27 22:57 CentOS-7-x86_64-DVD-1810.iso drwxr-xr-x. 2 root root 6 Apr 27 23:59 Desktop drwxr-xr-x. 2 root root 6 Apr 27 23:59 Documents drwxr-xr-x. 2 root root 6 Apr 27 23:59 Downloads drwxr-xr-x. 2 root root 6 Apr 27 23:59 Music drwxr-xr-x. 2 root root 6 Apr 27 23:59 Pictures drwxr-xr-x. 2 root root 6 Apr 27 23:59 Public drwxr-xr-x. 2 root root 6 Apr 27 23:59 Templates drwxr-xr-x. 2 root root 6 Apr 27 23:59 Videos [root@yanshi ~]# rm -rf CentOS-7-x86_64-DVD-1810.iso
- 到这里离线的yum源就配置完成了,这台服务器就可以做为yum服务器了,同一个网络下的其他服务器的yum配置成这个地址就可以使用该yum源了
- 如果我们在使用某些命令时提示【-bash: /usr/bin/unzip: 没有那个文件或目录】,则需要使用yum进行安装
[root@yanshi ~]# yum install -y unzip 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 正在解决依赖关系 --> 正在检查事务 ---> 软件包 unzip.x86_64.0.6.0-19.el7 将被 安装 --> 解决依赖关系完成 依赖关系解决 ======================================================================================================================================================== Package 架构 版本 源 大小 ======================================================================================================================================================== 正在安装: unzip x86_64 6.0-19.el7 server 170 k 事务概要 ======================================================================================================================================================== 安装 1 软件包 总下载量:170 k 安装大小:365 k Downloading packages: unzip-6.0-19.el7.x86_64.rpm | 170 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : unzip-6.0-19.el7.x86_64 1/1 验证中 : unzip-6.0-19.el7.x86_64 1/1 已安装: unzip.x86_64 0:6.0-19.el7 完毕!
- 如果我们想要移除unzip程序呢
[root@yanshi ~]# yum remove -y unzip 已加载插件:fastestmirror, langpacks 正在解决依赖关系 --> 正在检查事务 ---> 软件包 unzip.x86_64.0.6.0-19.el7 将被 删除 --> 解决依赖关系完成 依赖关系解决 ======================================================================================================================================================== Package 架构 版本 源 大小 ======================================================================================================================================================== 正在删除: unzip x86_64 6.0-19.el7 @server 365 k 事务概要 ======================================================================================================================================================== 移除 1 软件包 安装大小:365 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction 正在删除 : unzip-6.0-19.el7.x86_64 1/1 验证中 : unzip-6.0-19.el7.x86_64 1/1 删除: unzip.x86_64 0:6.0-19.el7 完毕!
本文作者:洋芋不是土豆
关于作者:分享自己的学习心得,请多多赐教!
联系方式(邮件):carsen2015@163.com
联系方式(QQ):1790356276(请备注来意)
本文链接:https://www.cnblogs.com/carsen/p/16858299.html
版权说明:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。