Linux-----httpd服务的配置(设置yum仓库)


httpd是Apache超文本传输协议(HTTP)服务器的主程序,直接执行程序即可启动该服务。

1:安装httpd安装包

[root@localhost ~]# yum -y install httpd        ###安装httpd
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
base                                                            | 3.6 kB  00:00:00     
extras                                                          | 2.9 kB  00:00:00     
updates                                                         | 2.9 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                   | 153 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                               | 194 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                              | 3.0 MB  00:00:01     
(4/4): base/7/x86_64/primary_db                                 | 6.1 MB  00:00:01     
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-93.el7.centos 将被 安装
--> 正在处理依赖关系 httpd-tools = 2.4.6-93.el7.centos,它被软件包 httpd-2.4.6-93.el7.centos.x86_64 需要
--> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-93.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 httpd-tools.x86_64.0.2.4.6-93.el7.centos 将被 安装
---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=======================================================================================
 Package              架构            版本                         源             大小
=======================================================================================
正在安装:
 httpd                x86_64          2.4.6-93.el7.centos          base          2.7 M
为依赖而安装:
 httpd-tools          x86_64          2.4.6-93.el7.centos          base           92 k
 mailcap              noarch          2.1.41-2.el7                 base           31 k

事务概要
=======================================================================================
安装  1 软件包 (+2 依赖软件包)

总下载量:2.8 M
安装大小:9.6 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/httpd-tools-2.4.6-93.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
httpd-tools-2.4.6-93.el7.centos.x86_64.rpm 的公钥尚未安装
(1/3): httpd-tools-2.4.6-93.el7.centos.x86_64.rpm               |  92 kB  00:00:00     
(2/3): mailcap-2.1.41-2.el7.noarch.rpm                          |  31 kB  00:00:00     
(3/3): httpd-2.4.6-93.el7.centos.x86_64.rpm                     | 2.7 MB  00:00:01     
---------------------------------------------------------------------------------------
总计                                                      2.3 MB/s | 2.8 MB  00:01     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 软件包     : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : mailcap-2.1.41-2.el7.noarch                                        1/3 
  正在安装    : httpd-tools-2.4.6-93.el7.centos.x86_64                             2/3 
  正在安装    : httpd-2.4.6-93.el7.centos.x86_64                                   3/3 
  验证中      : httpd-tools-2.4.6-93.el7.centos.x86_64                             1/3 
  验证中      : mailcap-2.1.41-2.el7.noarch                                        2/3 
  验证中      : httpd-2.4.6-93.el7.centos.x86_64                                   3/3 
已安装:
  httpd.x86_64 0:2.4.6-93.el7.centos                                           
作为依赖被安装:
  httpd-tools.x86_64 0:2.4.6-93.el7.centos        mailcap.noarch 0:2.1.41-2.el7       
完毕!

[root@localhost ~]# rpm -q httpd                 ##查看httpd是否安装   已安装
httpd-2.4.6-93.el7.centos.x86_64
[root@localhost ~]# systemctl restart httpd.service      ##开启服务
[root@localhost ~]# systemctl stop f
firewalld.service  fwupd.service
[root@localhost ~]# systemctl stop firewalld.service     ##关闭防火墙
[root@localhost ~]# setenforce 0                         ##关闭安全功能
 
[root@localhost ~]# ifconfig                             ##查询网络地址
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 20.0.0.41  netmask 255.255.255.0  broadcast 20.0.0.255
        inet6 fe80::fce1:77f:7a9:b103  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:84:c1:e3  txqueuelen 1000  (Ethernet)
        RX packets 10061  bytes 13392718 (12.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1931  bytes 164131 (160.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1255  bytes 106168 (103.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1255  bytes 106168 (103.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我们把地址复制到网站已经远程登录到apache

mark

2:离线状态下安装rpm软件包

2.1:模拟不能上网

首先把虚拟机的网络切换到仅主机模式,调到仅主机就已经不能上网了,这边我们说明一下仅主机是只能跟你宿主机或宿主机里的虚拟机通信,是无法访问外网的。

mark

2.2:修改静态地址

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33    ##编辑静态地址
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static                 ##设置静态IP
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=86503bd2-47b6-4518-8a5f-63e4de03d11e
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.138.100           ##设置IP地址
PREFIX=24                        ##子网掩码
GATEWAY=192.168.100.1            ##网关

~                    
:wq保存退出

[root@localhost ~]# ifconfig                 ##查看IP   已经设置好了
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.138.100  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::fce1:77f:7a9:b103  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:84:c1:e3  txqueuelen 1000  (Ethernet)
        RX packets 10258  bytes 13419212 (12.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2162  bytes 240508 (234.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1317  bytes 112184 (109.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1317  bytes 112184 (109.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:95:60:04  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost ~]#yun list     ##加载缓存
[root@localhost ~]# yum clean all            ##清除yum仓库缓存
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras updates
Cleaning up list of fastest mirrors
[root@localhost ~]# yum list               ##在加载缓存已经各种报错了
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"


 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

3:挂载镜像文件进行安装

mark

[root@localhost ~]# df -Th         ##查看挂载
文件系统                类型      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root xfs        54G  4.1G   50G    8% /
devtmpfs                devtmpfs  1.9G     0  1.9G    0% /dev
tmpfs                   tmpfs     1.9G     0  1.9G    0% /dev/shm
tmpfs                   tmpfs     1.9G   13M  1.9G    1% /run
tmpfs                   tmpfs     1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sda1               xfs      1014M  179M  836M   18% /boot
/dev/mapper/centos-home xfs       245G   33M  245G    1% /home
tmpfs                   tmpfs     378M  4.0K  378M    1% /run/user/42
tmpfs                   tmpfs     378M   36K  378M    1% /run/user/0
/dev/sr0                iso9660   4.3G  4.3G     0  100% /run/media/root/CentOS 7 x86_64

进行挂载
[root@localhost mnt]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost mnt]# df -Th
文件系统                类型      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root xfs        54G  4.1G   50G    8% /
devtmpfs                devtmpfs  1.9G     0  1.9G    0% /dev
tmpfs                   tmpfs     1.9G     0  1.9G    0% /dev/shm
tmpfs                   tmpfs     1.9G   13M  1.9G    1% /run
tmpfs                   tmpfs     1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sda1               xfs      1014M  179M  836M   18% /boot
/dev/mapper/centos-home xfs       245G   33M  245G    1% /home
tmpfs                   tmpfs     378M  4.0K  378M    1% /run/user/42
tmpfs                   tmpfs     378M   36K  378M    1% /run/user/0
/dev/sr0                iso9660   4.3G  4.3G     0  100% /mnt
[root@localhost etc]# ls /mnt     ##查看文件列表发现已经在了
CentOS_BuildTag  EFI  EULA  GPL  images  isolinux  LiveOS  Packages  repodata  RPM-GPG-KEY-CentOS-7  RPM-GPG-KEY-CentOS-Testing-7  TRANS.TBL

4:设置yum仓库

[root@localhost ~]# cd /mnt               ##进入mnt目录
[root@localhost mnt]# ls                  ##列出mnt目录 
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL
[root@localhost mnt]# cd Packages/         ##进入Packages目录
[root@localhost Packages]# ls              ##可以看出rpm的安装包都在这个目录下
389-ds-base-1.3.8.4-15.el7.x86_64.rpm
389-ds-base-libs-1.3.8.4-15.el7.x86_64.rpm
abattis-cantarell-fonts-0.0.25-1.el7.noarch.rpm
abrt-2.1.11-52.el7.centos.x86_64.rpm
abrt-addon-ccpp-2.1.11-52.el7.centos.x86_64.rpm
abrt-addon-kerneloops-2.1.11-52.el7.centos.x86_64.rpm
abrt-addon-pstoreoops-2.1.11-52.el7.centos.x86_64.rpm
abrt-addon-python-2.1.11-52.el7.centos.x86_64.rpm
abrt-addon-vmcore-2.1.11-52.el7.centos.x86_64.rpm
abrt-addon-xorg-2.1.11-52.el7.centos.x86_64.rpm
abrt-cli-2.1.11-52.el7.centos.x86_64.rpm
abrt-console-notification-2.1.11-52.el7.centos.x86_64.rpm
abrt-dbus-2.1.11-52.el7.centos.x86_64.rpm
abrt-desktop-2.1.11-52.el7.centos.x86_64.rpm
abrt-gui-2.1.11-52.el7.centos.x86_64.rpm
abrt-gui-libs-2.1.11-52.el7.centos.x86_64.rpm
yum不是需要联网才能用吗 我们可以把yum安装源设为Packages目录

[root@localhost Packages]# cd /etc/yum.repos.d/        ##进入yum仓库目录
[root@localhost yum.repos.d]# ls                    ##显示列表  下面这些文件需要联网才能用
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@localhost yum.repos.d]# mkdir tom      ##创建目录tom 
[root@localhost yum.repos.d]# mv CentOS-* tom/     ##我们把CentOS文件全部移到tom目录下
[root@localhost yum.repos.d]# ls
tom
[root@localhost yum.repos.d]# ls /tom
ls: 无法访问/tom: 没有那个文件或目录
[root@localhost yum.repos.d]# ls tom/         ##都已经在tom目录下面了
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@localhost yum.repos.d]# vim shuai.repo       ##编辑yum仓库

[yum cangku]            
name=test                         ##仓库名称test
baseurl=file:///mnt               ##仓库软件源
enabled=1                         ##开启yum仓库   0是关闭 
gpgcheck=0                        ##关闭密钥检查
~          
:wq保存退出

[root@localhost yum.repos.d]# yum list          ##释放yum缓存    已经不报错了
xvattr.x86_64                           1.3-27.el7                     @anaconda
xz.x86_64                               5.2.2-1.el7                    @anaconda
xz-libs.x86_64                          5.2.2-1.el7                    @anaconda
yajl.x86_64                             2.0.4-4.el7                    @anaconda
yelp.x86_64                             2:3.28.1-1.el7                 @anaconda
yelp-libs.x86_64                        2:3.28.1-1.el7                 @anaconda
yelp-xsl.noarch                         3.28.0-1.el7                   @anaconda
yum.noarch                              3.4.3-161.el7.centos           @anaconda
yum-langpacks.noarch                    0.4.2-7.el7                    @anaconda
yum-metadata-parser.x86_64              1.1.4-10.el7                   @anaconda
yum-plugin-fastestmirror.noarch         1.1.31-50.el7                  @anaconda
yum-utils.noarch                        1.1.31-50.el7                  @anaconda
zenity.x86_64                           3.28.1-1.el7                   @anaconda
zip.x86_64                              3.0-11.el7                     @anaconda
zlib.x86_64                             1.2.7-18.el7                   @anaconda
......省略

5:测试yum仓库安装

测试
[root@localhost ~]# yum remove httpd          ##卸载安装的httpd
已加载插件:fastestmirror, langpacks
Bad id for repo: yum cangku, byte =   3
正在解决依赖关系
--> 正在检查事务
---> 软件包 httpd.x86_64.0.2.4.6-93.el7.centos 将被 删除
--> 解决依赖关系完成

依赖关系解决

================================================================================

 Package       架构           版本                          源             大小
================================================================================

正在删除:
 httpd         x86_64         2.4.6-93.el7.centos           @base         9.4 M

事务概要
================================================================================

移除  1 软件包

安装大小:9.4 M
是否继续?[y/N]:y                          ##y确定
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在删除    : httpd-2.4.6-93.el7.centos.x86_64                            1/1 
  验证中      : httpd-2.4.6-93.el7.centos.x86_64                            1/1 

删除:

[root@localhost ~]# yum -y install httpd        ###安装httpd  
已加载插件:fastestmirror, langpacks
Determining fastest mirrors

 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
   base                                                            | 3.6 kB  00:00:00     
   extras                                                          | 2.9 kB  00:00:00     
   updates                                                         | 2.9 kB  00:00:00     
   (1/4): base/7/x86_64/group_gz                                   | 153 kB  00:00:00     
   (2/4): extras/7/x86_64/primary_db                               | 194 kB  00:00:00     
   (3/4): updates/7/x86_64/primary_db                              | 3.0 MB  00:00:01     
   (4/4): base/7/x86_64/primary_db                                 | 6.1 MB  00:00:01     
   正在解决依赖关系
   --> 正在检查事务
   ---> 软件包 httpd.x86_64.0.2.4.6-93.el7.centos 将被 安装
   --> 正在处理依赖关系 httpd-tools = 2.4.6-93.el7.centos,它被软件包 httpd-2.4.6-93.el7.centos.x86_64 需要
   --> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-93.el7.centos.x86_64 需要
   --> 正在检查事务
   ---> 软件包 httpd-tools.x86_64.0.2.4.6-93.el7.centos 将被 安装
   ---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
   --> 解决依赖关系完成

依赖关系解决

=======================================================================================

 Package              架构            版本                         源             大小
=======================================================================================

正在安装:
 httpd                x86_64          2.4.6-93.el7.centos          base          2.7 M
为依赖而安装:
 httpd-tools          x86_64          2.4.6-93.el7.centos          base           92 k
 mailcap              noarch          2.1.41-2.el7                 base       
[root@localhost ~]# systemctl restart httpd                ##重启服务
[root@localhost ~]# systemctl stop firewalld.service       ##关闭防火墙
[root@localhost ~]# setenforce 0                           ##关闭安全功能

成功

mark

猜你喜欢

转载自blog.csdn.net/weixin_47151643/article/details/107145323