搞它!!!深入了解安装及管理程序,学会使用rpm工具 虚拟机实验下载安装Apache

时间:2022-07-24
本文章向大家介绍搞它!!!深入了解安装及管理程序,学会使用rpm工具 虚拟机实验下载安装Apache,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

前言:

了解Linux应用程序基础,学习如何查询RPM软件包信息了解安装、升级、卸载、RPM软件包 ,如何与运用yum仓库,学习源代码编译安装

一、Linux应用程序基础

1、应用程序与系统命令的关系

2、典型应用程序的目录结构

3、常见的软件包封装类型

1.rpm:自动安装包,把安装过程的各种操作编译封装到里面,适合新手使用

2.deb:在乌班图(ubuntu,是界面)系统中使用,不在centos中使用

​ 题外话:1.LINUX家族,下面Redhat,红帽 三个认证(开源但是不是免费,基础服务免费)

​ 因为红帽的这个原因,有人不爽,就由此产生了社区(系统开发者,都是大佬),他们设计了centos

​ 服务器中用centos的多,政府不差钱,用的红帽的多

​ 有一个面向客户端的linux系统的是ubuntu系统(最好用),开源,纯免费,特别适用于软件开发人群

​ 全球中最好用,中国用不了,因为长城防火墙挡住了

​ 3.debian,是linux的早期版本系统,是乌版图的前身,服务端和客户端都具备功能后来衍生出了乌版图和kaili

​ 4.kaili是黑客专用的渗透工具,包括攻防攻击

​ kaili占用资源很少,通常是安装在树莓派中

​ 5.suse是德国的linux系统,被ISP运营商所使用(电信,移动,联通) 定制版

源代码软件包:原始代码,是人能看得懂的

jazz——————class,class看不懂,是机器能识别的

绿色免安装的软件包:解压后可以直接使用

4、RPM包管理工具

yum可以解决RPM的依赖关系

红色是名字,版本号,发布次数

版本号第一个是大版本,第二个是小版本

i386,i686出现,就代表是32位系统

64位可以最大支持2t内存,瓶颈在于读写

现在已经有了内存数据库,redis

服务器只能插半高显卡

二、查询RPM软件包信息

1、查询已安装的RPM软件信息

rpm -q【子选项】 【软件名】

-q 查看基本信息,即是否安装

[root@localhost ~]# rpm -q httpd	#查询httpd工具是否已安装
未安装软件包 httpd 

常用选项

-qa 查看系统已安装的所有软件包

grep 过滤筛选

[root@localhost ~]# rpm -qa		#查询当前系统已安装的所有软件包,显示过多,这里就不展示
[root@localhost ~]# rpm -qa | grep "mdadm"	#后面加| grep筛选出想要查询的信息
mdadm-4.0-5.el7.x86_64

-qi 查看已安装的软件包的详细信息,-q已安装,-i(information),组合起来用

[root@localhost ~]# rpm -qi mdadm	#查看mdadm的详细信息
Name        : mdadm
Version     : 4.0
Release     : 5.el7
Architecture: x86_64
Install Date: 2019年10月23日 星期三 13时36分47秒
Group       : System Environment/Base
Size        : 1044798
License     : GPLv2+
Signature   : RSA/SHA256, 2017年08月11日 星期五 02时20分11秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : mdadm-4.0-5.el7.src.rpm
Build Date  : 2017年08月05日 星期六 05时44分20秒
Build Host  : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://www.kernel.org/pub/linux/utils/raid/mdadm/
Summary     : The mdadm program controls Linux md devices (software RAID arrays)
Description :
The mdadm program is used to create, manage, and monitor Linux MD (software
RAID) devices.  As such, it provides similar functionality to the raidtools
package.  However, mdadm is a single program, and it can perform
almost all functions without a configuration file, though a configuration
file can be used to help with some common tasks.

-ql 查看软件包安装的所有的文件列表(list)

[root@localhost ~]# rpm -ql mdadm	
/etc/cron.d/raid-check
/etc/libreport/events.d/mdadm_event.conf
/etc/sysconfig/raid-check
/usr/lib/systemd/system-shutdown/mdadm.shutdown
/usr/lib/systemd/system/mdadm-grow-continue@.service
/usr/lib/systemd/system/mdadm-last-resort@.service
/usr/lib/systemd/system/mdadm-last-resort@.timer
/usr/lib/systemd/system/mdmon@.service
/usr/lib/systemd/system/mdmonitor.service
/usr/lib/tmpfiles.d/mdadm.conf
/usr/lib/udev/rules.d/63-md-raid-arrays.rules
/usr/lib/udev/rules.d/65-md-incremental.rules
/usr/sbin/mdadm
/usr/sbin/mdmon
/usr/sbin/raid-check
/usr/share/doc/mdadm-4.0
/usr/share/doc/mdadm-4.0/COPYING
/usr/share/doc/mdadm-4.0/ChangeLog
/usr/share/doc/mdadm-4.0/TODO
/usr/share/doc/mdadm-4.0/mdadm.conf-example
/usr/share/doc/mdadm-4.0/mdcheck
/usr/share/doc/mdadm-4.0/syslog-events
/usr/share/man/man4/md.4.gz
/usr/share/man/man5/mdadm.conf.5.gz
/usr/share/man/man8/mdadm.8.gz
/usr/share/man/man8/mdmon.8.gz
/var/run/mdadm

-qf 根据已知的文件,去查看它属于哪个软件包,由哪个软件包所安装

[root@localhost ~]# rpm -qf /usr/sbin/mdmon	
mdadm-4.0-5.el7.x86_64

-qc 查看软件包的所有配置文件 (配置文件后缀 conf,cnf,ini;前两个看得多,PHP的文件是inin)

[root@localhost ~]# rpm -qc mdadm
/etc/cron.d/raid-check
/etc/sysconfig/raid-check
/usr/lib/tmpfiles.d/mdadm.conf

-qd 查看软件包的文档有哪些(what),在哪些位置(where)

[root@localhost ~]# rpm -qd mdadm
/usr/share/doc/mdadm-4.0/COPYING
/usr/share/doc/mdadm-4.0/ChangeLog
/usr/share/doc/mdadm-4.0/TODO
/usr/share/doc/mdadm-4.0/mdadm.conf-example
/usr/share/doc/mdadm-4.0/mdcheck
/usr/share/doc/mdadm-4.0/syslog-events
/usr/share/man/man4/md.4.gz
/usr/share/man/man5/mdadm.conf.5.gz
/usr/share/man/man8/mdadm.8.gz
/usr/share/man/man8/mdmon.8.gz

2 、查询未安装的RPM软件包文件中信息

rpm -qp 【子选项】RPM包文件

常用选项

-qpi 查看未安装的软件包的详细信息

-qpl 查看未安装软件包的所有文件

-qpc 查看未安装软件包的所有配置文件 (配置文件后缀 conf,cnf,ini;前两个看得多,PHP的文件是inin)

-qpd 查看未安装软件包的文档 小结:未安装的命令选项就是在已安装的命令选项上多一个p,没有-a,-f子选项

三:安装、升级、卸载RPM软件包

1、安装或升级RPM软件包

安装或升级RPM软件

rpm 【选项】 RPM包文件

常用选项

-i install 安装软件包

-U 更新软件包,若没有该软件包,则自动安装该软件

-F 检查更新软件包,若没有该软件包,不会自动安装该软件

2、卸载指定的RPM软件

rpm -e 软件名

-e 卸载

3 、辅助选项

–force 强制执行

–nodeps 解决依赖性关系(但是基本上没啥用,因为这个命令的作用是忽略依赖关系,直接安装,治标不治本)

-h 友好显示(即以#号键显示安装进度条)

-v 显示详细过程信息

例如:rpm -qd httpd 查看httpd的安装包的文档

yum remore httpd -y 重新安装httpd

rpm -ivh 安装并显示进度和详细过程

rpm -evh 卸载并显示进度和详细过程

4、维护RPM数据库

init 初始化的意思,rebuild重建 db(database)数据库

导入验证公共密钥 --import 导入的意思,仅作校验作用,没有其他作用

5、使用rpm软件实验

1.点开虚拟机,配置把镜像文件挂载进去,在右下角cd中,虚拟机设置,设备状态勾选已连接 2.接下来进行挂载

[root@localhost ~]# cd /dev
[root@localhost dev]# ls
agpgart          log                 sda2      tty15  tty42  ttyS3
autofs           loop-control        sdb       tty16  tty43  uhid
block            lp0                 sdb1      tty17  tty44  uinput
bsg              lp1                 sdc       tty18  tty45  urandom
btrfs-control    lp2                 sdc1      tty19  tty46  usbmon0
bus              lp3                 sdd       tty2   tty47  usbmon1
cdrom            mapper              sdd1      tty20  tty48  usbmon2
centos           mcelog              sde       tty21  tty49  vcs
char             md0                 sde1      tty22  tty5   vcs1
console          md1                 sg0       tty23  tty50  vcs2
core             md2                 sg1       tty24  tty51  vcs3
cpu              mem                 sg2       tty25  tty52  vcs4
cpu_dma_latency  mqueue              sg3       tty26  tty53  vcs5
crash            net                 sg4       tty27  tty54  vcs6
disk             network_latency     sg5       tty28  tty55  vcsa
dm-0             network_throughput  shm       tty29  tty56  vcsa1
dm-1             null                snapshot  tty3   tty57  vcsa2
dm-2             nvram               snd       tty30  tty58  vcsa3
dri              oldmem              sr0       tty31  tty59  vcsa4
fb0              port                stderr    tty32  tty6   vcsa5
fd               ppp                 stdin     tty33  tty60  vcsa6
full             ptmx                stdout    tty34  tty61  vfio
fuse             pts                 tty       tty35  tty62  vga_arbiter
hidraw0          random              tty0      tty36  tty63  vhci
hpet             raw                 tty1      tty37  tty7   vhost-net
hugepages        rfkill              tty10     tty38  tty8   vmci
hwrng            rtc                 tty11     tty39  tty9   vsock
initctl          rtc0                tty12     tty4   ttyS0  zero
input            sda                 tty13     tty40  ttyS1
kmsg             sda1                tty14     tty41  ttyS2

mout 设备名称 挂载点(本地目录)

mount /dev/sr0(光盘驱动设备) 或 /mnt/

[root@localhost dev]# mount /dev/sr0 /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost dev]# ls -l /mnt
总用量 664
-rw-rw-r--. 3 root root     14 9月   5 2017 CentOS_BuildTag
drwxr-xr-x. 3 root root   2048 9月   5 2017 EFI
-rw-rw-r--. 3 root root    227 8月  30 2017 EULA
-rw-rw-r--. 3 root root  18009 12月 10 2015 GPL
drwxr-xr-x. 3 root root   2048 9月   5 2017 images
drwxr-xr-x. 2 root root   2048 9月   5 2017 isolinux
drwxr-xr-x. 2 root root   2048 9月   5 2017 LiveOS
drwxrwxr-x. 2 root root 641024 9月   5 2017 Packages
drwxr-xr-x. 2 root root   4096 9月   5 2017 repodata
-rw-rw-r--. 3 root root   1690 12月 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 3 root root   1690 12月 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root   2883 9月   6 2017 TRANS.TBL

RPM-GPG-KEY-CentOS-7就是光驱内的公钥 光驱里面的packages目录 专门存放软件包

bind没有安装,可以安装个bind(DNS方面的工具)软件

[root@localhost Packages]# rpm -q bind
未安装软件包 bind 

[root@localhost Packages]# rpm -ivh bind- 
#此时按两下tab键,可以把前面为bind的文件全部展示出来
bind-9.9.4-50.el7.x86_64.rpm
bind-chroot-9.9.4-50.el7.x86_64.rpm
bind-dyndb-ldap-11.1-3.el7.x86_64.rpm
bind-libs-9.9.4-50.el7.x86_64.rpm
bind-libs-lite-9.9.4-50.el7.x86_64.rpm
bind-license-9.9.4-50.el7.noarch.rpm
bind-pkcs11-9.9.4-50.el7.x86_64.rpm
bind-pkcs11-libs-9.9.4-50.el7.x86_64.rpm
bind-pkcs11-utils-9.9.4-50.el7.x86_64.rpm
bind-utils-9.9.4-50.el7.x86_64.rpm
[root@localhost Packages]# rpm -ivh bind-9.9.4-50.el7.x86_64.rpm  
警告:bind-9.9.4-50.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:bind-32:9.9.4-50.el7             ################################# [100%]

可以-q查看验证一下,还有-ql,-qc,-qf,-qd等选项可以试一试

[root@localhost Packages]# rpm -q bind
bind-9.9.4-50.el7.x86_64

然后再试试卸载命令-e

[root@localhost Packages]# rpm -evh bind
准备中...                          ################################# [100%]
正在清理/删除...
   1:bind-32:9.9.4-50.el7             ################################# [100%]
[root@localhost Packages]# rpm -q bind 	#验证是否已卸载
未安装软件包 bind 

bind没有依赖关系,httpd有依赖关系

[root@localhost Packages]# rpm -ivh httpd-2.4.6-67.el7.centos.x86_64.rpm 
警告:httpd-2.4.6-67.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
	/etc/mime.types 被 httpd-2.4.6-67.el7.centos.x86_64 需要
	httpd-tools = 2.4.6-67.el7.centos 被 httpd-2.4.6-67.el7.centos.x86_64 需要
	libapr-1.so.0()(64bit) 被 httpd-2.4.6-67.el7.centos.x86_64 需要
	libaprutil-1.so.0()(64bit) 被 httpd-2.4.6-67.el7.centos.x86_64 需要

rpm自带解决依赖关系,所以就如上所示,就要一直下载被依赖的软件包 所以在生产环境中就会很少用,可能一个软件会逼得你转行—

6、解决软件包依赖关系方法

1)安装有依赖关系的多个软件时 被依赖的软件包需要先安装

可同时指定多个.rpm包文件进行安装

2)卸载有依赖关系的多个软件时 依赖其他程序的软件包需要先卸载

可同时指定多个软件名进行卸载

3)忽略依赖关系 结合“–nodeps”选项,但可能导致软件异常 重点记住:

使用rpm命令查询RPM软件信息的常用选项

使用rpm命令安装、升级、卸载RPM软件包的常用选项

典型应用程序的目录结构

常见的软件包封装类型

四、源代码编译安装

1、源代码编译概述

1)使用源代码安装软件的优点

获得最新的软件版本,及时修复bug

根据用户需要,灵活定制软件功能

2)应用场合举例

安装较新版本的应用程序时

当前安装的程序无法满足需要时

需要为应用程序添加新的功能时

源代码安装模式可以视为iDIY模式,可以自定义自己的需要安装,依据官方发布的对应版本的软件手册操作

2、编译安装源代码包

1)Tarball封包

.tar.gz和.tar.bz2格式居多

软件素材参考:http://sourceforge.net

2)完整性校验

md5sum 校验工具命令

除此之外还有zip压缩包, unzip 解压命令 -d 指定解压为位置

unzip 软件包名 -d 解压至指定路径

mount.cifs //192.168.254.10/linuxs /abc 挂载

[root@localhost ~]# mkdir /abc
[root@localhost ~]# mount.cifs //192.168.254.10/linuxs /abc
Password for root@//192.168.254.10/linuxs:  
[root@localhost /]# cd /abc
[root@localhost abc]# ls
apr-1.4.6.tar.gz  apr-util-1.4.1.tar.gz  httpd-2.4.2.tar.gz

解压三个gz压缩包

[root@localhost abc]# tar -xzvf apr-util-1.4.1.tar.gz -C /opt
'tar -x解压 -z指gzip格式 -v显示详细过程 -f 执行 压缩包 -C 指定解压目标路径'
[root@localhost abc]# tar -xzvf apr-1.4.6.tar.gz -C /opt
[root@localhost abc]# tar -xzvf httpd-2.4.2.tar.gz -C /opt

yum install gcc gcc-c++ 使用yum自动安装gcc gcc-c++ 编译器

[root@localhost abc]# yum install gcc gcc-c++

3、编译安装过程

4 、手工编译安装四步骤

1) tar解包 1)习惯上将软件包释放到/usr/src/目录

2)解包后的软代码文件位置:

/usr/stc/软件名-版本号/ 3)实例

(2)./configure 配置 1)使用源码目录中的configure脚本

2)执行“./configure 00help”可查看帮助

3)典型的配置选项

–prefix=软件安装目录 4)示例

(3)make编译(make是转编译的过程) 执行make命令

(4)make安装 执行make install 命令

示例

安装后的测试、应用、维护软件

使用前

启动Apache 运行lynx 127.0.0.1查看本机Apache运行状态 (httpd.conf httpd 配置文件 apachectl start 启动apache)

手工编译安装步骤小结

1:找到源码包 先挂载,在宿主机共享目录内找到要安装的压缩包

[root@localhost ~]# mkdir /abc
[root@localhost ~]# mount.cifs //192.168.254.10/linuxs /abc
Password for root@//192.168.254.10/linuxs:  
[root@localhost /]# cd /abc
[root@localhost abc]# ls
apr-1.4.6.tar.gz  apr-util-1.4.1.tar.gz  httpd-2.4.2.tar.gz

2:解压源码包到指定位置

[root@localhost abc]# tar -xzvf apr-util-1.4.1.tar.gz -C /opt
'tar -x解压 -z指gzip格式 -v显示详细过程 -f 执行 压缩包 -C 指定解压目标路径'
[root@localhost abc]# tar -xzvf apr-1.4.6.tar.gz -C /opt
[root@localhost abc]# tar -xzvf httpd-2.4.2.tar.gz -C /opt

接下来把apr-1.4.6和apr-until-1.4.1放入到httpd对应的目录内

[root@localhost abc]# cd /opt	'切换到/opt'
[root@localhost opt]# ls
apr-1.4.6  apr-util-1.4.1  httpd-2.4.2  rh
[root@localhost opt]# mv apr-1.4.6/ httpd-2.4.2/srclib/apr	
[root@localhost opt]# mv apr-util-1.4.1/ httpd-2.4.2/srclib/apr-until
[root@localhost opt]# cd httpd-2.4.2/srclib/
[root@localhost srclib]# ls
apr  apr-until  Makefile.in
[root@localhost srclib]# cd ../../

软件包整理完毕,接下来进行配置 3:configure配置 先提前安装下编译软件,先安装环境包,即编译器等相关软件

pcre作用在网页当中的语言

zlib是网页压缩处理的图片传输

[root@localhost opt]# yum install gcc gcc-c++ pcre pcre-devel zlib-devel -y
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.cn99.com
 * updates: mirrors.163.com
软件包 gcc-4.8.5-39.el7.x86_64 已安装并且是最新版本
软件包 gcc-c++-4.8.5-39.el7.x86_64 已安装并且是最新版本
软件包 pcre-8.32-17.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 pcre-devel.x86_64.0.8.32-17.el7 将被 安装
---> 软件包 zlib-devel.x86_64.0.1.2.7-18.el7 将被 安装
--> 正在处理依赖关系 zlib = 1.2.7-18.el7,它被软件包 zlib-devel-1.2.7-18.el7.x86_64 需要
--> 正在检查事务
---> 软件包 zlib.x86_64.0.1.2.7-17.el7 将被 升级
---> 软件包 zlib.x86_64.0.1.2.7-18.el7 将被 更新
--> 解决依赖关系完成

依赖关系解决

========================================================================================
 Package               架构              版本                     源               大小
========================================================================================
正在安装:
 pcre-devel            x86_64            8.32-17.el7              base            480 k
 zlib-devel            x86_64            1.2.7-18.el7             base             50 k
为依赖而更新:
 zlib                  x86_64            1.2.7-18.el7             base             90 k

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

总下载量:619 k
Downloading packages:
No Presto metadata available for base
(1/3): zlib-devel-1.2.7-18.el7.x86_64.rpm                        |  50 kB  00:00:00     
(2/3): pcre-devel-8.32-17.el7.x86_64.rpm                         | 480 kB  00:00:00     
(3/3): zlib-1.2.7-18.el7.x86_64.rpm                              |  90 kB  00:00:00     
----------------------------------------------------------------------------------------
总计                                                       1.2 MB/s | 619 kB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : zlib-1.2.7-18.el7.x86_64                                            1/4 
  正在安装    : zlib-devel-1.2.7-18.el7.x86_64                                      2/4 
  正在安装    : pcre-devel-8.32-17.el7.x86_64                                       3/4 
  清理        : zlib-1.2.7-17.el7.x86_64                                            4/4 
  验证中      : pcre-devel-8.32-17.el7.x86_64                                       1/4 
  验证中      : zlib-1.2.7-18.el7.x86_64                                            2/4 
  验证中      : zlib-devel-1.2.7-18.el7.x86_64                                      3/4 
  验证中      : zlib-1.2.7-17.el7.x86_64                                            4/4 

已安装:
  pcre-devel.x86_64 0:8.32-17.el7            zlib-devel.x86_64 0:1.2.7-18.el7           

作为依赖被升级:
  zlib.x86_64 0:1.2.7-18.el7                                                            

完毕!

configure配置

[root@localhost httpd-2.4.2]# ./configure --prefix=/usr/local/httpd --enable-deflate --enable-so --enable-rewrite --enable-charset-lite -enable-cgi

4:make编译

[root@localhost httpd-2.4.2]# make		'编译,进入目录'

/opt/httpd-2.4.2/srclib/apr/libtool --silent --mode=link gcc -std=gnu99 -g -O2 -pthread          -o mod_alias.la -rpath /usr/local/httpd/modules -module -avoid-version  mod_alias.lo 
/opt/httpd-2.4.2/srclib/apr/libtool --silent --mode=compile gcc -std=gnu99 -g -O2 -pthread     -D_REENTRANT -D_GNU_SOURCE    -I. -I/opt/httpd-2.4.2/os/unix -I/opt/httpd-2.4.2/include -I/opt/httpd-2.4.2/srclib/apr/include -I/opt/httpd-2.4.2/srclib/apr-util/include -I/opt/httpd-2.4.2/srclib/apr-util/xml/expat/lib -I/opt/httpd-2.4.2/modules/aaa -I/opt/httpd-2.4.2/modules/cache -I/opt/httpd-2.4.2/modules/core -I/opt/httpd-2.4.2/modules/database -I/opt/httpd-2.4.2/modules/filters -I/opt/httpd-2.4.2/modules/ldap -I/opt/httpd-2.4.2/modules/loggers -I/opt/httpd-2.4.2/modules/lua -I/opt/httpd-2.4.2/modules/proxy -I/opt/httpd-2.4.2/modules/session -I/opt/httpd-2.4.2/modules/ssl -I/opt/httpd-2.4.2/modules/test -I/opt/httpd-2.4.2/server -I/opt/httpd-2.4.2/modules/arch/unix -I/opt/httpd-2.4.2/modules/dav/main -I/opt/httpd-2.4.2/modules/generators -I/opt/httpd-2.4.2/modules/mappers -prefer-pic -c mod_rewrite.c && touch mod_rewrite.slo
/opt/httpd-2.4.2/srclib/apr/libtool --silent --mode=link gcc -std=gnu99 -g -O2 -pthread          -o mod_rewrite.la -rpath /usr/local/httpd/modules -module -avoid-version  mod_rewrite.lo 
make[4]: 离开目录“/opt/httpd-2.4.2/modules/mappers”
make[3]: 离开目录“/opt/httpd-2.4.2/modules/mappers”
make[2]: 离开目录“/opt/httpd-2.4.2/modules”
make[2]: 进入目录“/opt/httpd-2.4.2/support”
make[2]: 离开目录“/opt/httpd-2.4.2/support”

make[1]: 离开目录“/opt/httpd-2.4.2”

中间可能会出现一些报错问题:环境包问题,配置格式问题,功能性方面问题(软件版本,是否支持功能),这些就需要仔细排查,缺什么补什么

5:make安装

make install 命令
[root@localhost httpd-2.4.2]# make install	'安装'
Installing icons
mkdir /usr/local/httpd/icons
mkdir /usr/local/httpd/logs
Installing CGIs
mkdir /usr/local/httpd/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /usr/local/httpd/man
mkdir /usr/local/httpd/man/man1
mkdir /usr/local/httpd/man/man8
mkdir /usr/local/httpd/manual
make[1]: 离开目录“/opt/httpd-2.4.2”

配置httpd的conf属性

[root@localhost httpd-2.4.2]# cd /usr/local		'进入到安装路径'
[root@localhost local]# ls
bin  etc  games  httpd  include  lib  lib64  libexec  sbin  share  src
[root@localhost local]# cd httpd/
[root@localhost httpd]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
[root@localhost httpd]# cd conf/
[root@localhost conf]# ls
extra  httpd.conf  magic  mime.types  original

安装完成后优化,即测试、应用维护软件 1:找到服务配置文件,修改功能 conf配置文件

[root@localhost conf]# vim httpd.conf	'配置httpd。conf'
:set nu 	'显示行数'
/Listen 	’查找Listen‘
46 # directive.
 47 #
 48 # Change this to Listen on specific IP addresses as shown below to 
 49 # prevent Apache from glomming onto all bound IP addresses.
 50 #
 51 #Listen 12.34.56.78:80
 52 Listen 80
 53 
 54 #
 55 # Dynamic Shared Object (DSO) Support
 56 #

修改IP地址(在这里每一行的前面若是有#键,则代表是注释行,不发挥功能,若要发挥功能,则要取消注释#键)

# 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 192.168.139.147:80	'去掉前面#号键,后面加端口号'
#Listen 80	'开启前面#号键'

#
# Dynamic Shared Object (DSO) Support

搜索Server

# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80		'修改网址'

#
# Deny access to the entirety of your server's filesystem. You must
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName www.kgc.com:80		'关掉前面#号键'

#
# Deny access to the entirety of your server's filesystem. You must
:wq   	'保存退出'

查看对应80端口是否启用

关闭防火墙

[root@localhost bin]# ./apachectl start		'开启apachctl'
[root@localhost bin]# netstat  -ntap |grep 80
tcp        0      0 192.168.139.147:80      0.0.0.0:*               LISTEN      73721/httpd         
[root@localhost bin]# systemctl stop firewalld.service		'关闭防火墙'
[root@localhost bin]# setenforce 0	
[root@localhost bin]# cd ..
[root@localhost httpd]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual

htdocs 网页目录,修改首页index配置

[root@localhost httpd]# cd htdocs/
[root@localhost htdocs]# ls
index.html
[root@localhost htdocs]# vim index.html 

vim index.html

<html><body><h1>this is test 咸蛋超人</h1></body></html>
~                                                                                       
~                                                                                       
~                                                                                       
~                                                                                       
~                             

打开之前输入的ip地址