ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

29.第八章 软件包管理(三)

2021-10-30 19:02:23  阅读:362  来源: 互联网

标签:httpd cmatrix -- tree 29 第八章 ... 软件包 root


4.3.11 实现私用 yum仓库

下载所有yum仓库的相关包和meta 数据

#CentOS 8 dnf 工具集成
dnf reposync --help #查看帮助

#默认只下载rpm包,不下载meta数据,需要指定--download-metadata 才能下载meta
dnf reposync --repoid=REPOID --download-metadata -p /path

#CentOS 7 以前版本,reposync工具来自于yum-utils包
reposync --repoid=REPOID --download-metadata -p /path

创建私有yum仓库:

createrepo [options] <directory>

范例:

[root@rocky8 ~]# dnf reposync --help
usage: dnf reposync [-c [config file]] [-q] [-v] [--version]
                    [--installroot [path]] [--nodocs] [--noplugins]
                    [--enableplugin [plugin]] [--disableplugin [plugin]]
                    [--releasever RELEASEVER] [--setopt SETOPTS]
                    [--skip-broken] [-h] [--allowerasing] [-b | --nobest] [-C]
                    [-R [minutes]] [-d [debug level]] [--debugsolver]
                    [--showduplicates] [-e ERRORLEVEL] [--obsoletes]
                    [--rpmverbosity [debug level name]] [-y] [--assumeno]
                    [--enablerepo [repo]] [--disablerepo [repo] | --repo
                    [repo]] [--enable | --disable] [-x [package]]
                    [--disableexcludes [repo]] [--repofrompath [repo,path]]
                    [--noautoremove] [--nogpgcheck] [--color COLOR]
                    [--refresh] [-4] [-6] [--destdir DESTDIR] [--downloadonly]
                    [--comment COMMENT] [--bugfix] [--enhancement]
                    [--newpackage] [--security] [--advisory ADVISORY]
                    [--bz BUGZILLA] [--cve CVES]
                    [--sec-severity {Critical,Important,Moderate,Low}]
                    [--forcearch ARCH] [-a [arch]] [--delete]
                    [--download-metadata] [-g] [-m]
                    [--metadata-path METADATA_PATH] [-n] [--norepopath]
                    [-p DOWNLOAD_PATH] [--remote-time] [--source] [-u]

download all packages from remote repo

General DNF options:
  -c [config file], --config [config file]
                        config file location
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  --version             show DNF version and exit
  --installroot [path]  set install root
  --nodocs              do not install documentations
  --noplugins           disable all plugins
  --enableplugin [plugin]
                        enable plugins by name
  --disableplugin [plugin]
                        disable plugins by name
  --releasever RELEASEVER
                        override the value of $releasever in config and repo
                        files
  --setopt SETOPTS      set arbitrary config and repo options
  --skip-broken         resolve depsolve problems by skipping packages
  -h, --help, --help-cmd
                        show command help
  --allowerasing        allow erasing of installed packages to resolve
                        dependencies
  -b, --best            try the best available package versions in
                        transactions.
  --nobest              do not limit the transaction to the best candidate
  -C, --cacheonly       run entirely from system cache, don't update cache
  -R [minutes], --randomwait [minutes]
                        maximum command wait time
  -d [debug level], --debuglevel [debug level]
                        debugging output level
  --debugsolver         dumps detailed solving results into files
  --showduplicates      show duplicates, in repos, in list/search commands
  -e ERRORLEVEL, --errorlevel ERRORLEVEL
                        error output level
  --obsoletes           enables dnf's obsoletes processing logic for upgrade
                        or display capabilities that the package obsoletes for
                        info, list and repoquery
  --rpmverbosity [debug level name]
                        debugging output level for rpm
  -y, --assumeyes       automatically answer yes for all questions
  --assumeno            automatically answer no for all questions
  --enablerepo [repo]   Enable additional repositories. List option. Supports
                        globs, can be specified multiple times.
  --disablerepo [repo]  Disable repositories. List option. Supports globs, can
                        be specified multiple times.
  --repo [repo], --repoid [repo]
                        enable just specific repositories by an id or a glob,
                        can be specified multiple times
  --enable              enable repos with config-manager command
                        (automatically saves)
  --disable             disable repos with config-manager command
                        (automatically saves)
  -x [package], --exclude [package], --excludepkgs [package]
                        exclude packages by name or glob
  --disableexcludes [repo], --disableexcludepkgs [repo]
                        disable excludepkgs
  --repofrompath [repo,path]
                        label and path to an additional repository to use
                        (same path as in a baseurl), can be specified multiple
                        times.
  --noautoremove        disable removal of dependencies that are no longer
                        used
  --nogpgcheck          disable gpg signature checking (if RPM policy allows)
  --color COLOR         control whether color is used
  --refresh             set metadata as expired before running the command
  -4                    resolve to IPv4 addresses only
  -6                    resolve to IPv6 addresses only
  --destdir DESTDIR, --downloaddir DESTDIR
                        set directory to copy packages to
  --downloadonly        only download packages
  --comment COMMENT     add a comment to transaction
  --bugfix              Include bugfix relevant packages, in updates
  --enhancement         Include enhancement relevant packages, in updates
  --newpackage          Include newpackage relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory ADVISORY, --advisories ADVISORY
                        Include packages needed to fix the given advisory, in
                        updates
  --bz BUGZILLA, --bzs BUGZILLA
                        Include packages needed to fix the given BZ, in
                        updates
  --cve CVES, --cves CVES
                        Include packages needed to fix the given CVE, in
                        updates
  --sec-severity {Critical,Important,Moderate,Low}, --secseverity {Critical,Important,Moderate,Low}
                        Include security relevant packages matching the
                        severity, in updates
  --forcearch ARCH      Force the use of an architecture

Reposync command-specific options:
  -a [arch], --arch [arch]
                        download only packages for this ARCH
  --delete              delete local packages no longer present in repository
  --download-metadata   download all the metadata.
  -g, --gpgcheck        Remove packages that fail GPG signature checking after
                        downloading
  -m, --downloadcomps   also download and uncompress comps.xml
  --metadata-path METADATA_PATH
                        where to store downloaded repository metadata.
                        Defaults to the value of --download-path.
  -n, --newest-only     download only newest packages per-repo
  --norepopath          Don't add the reponame to the download path.
  -p DOWNLOAD_PATH, --download-path DOWNLOAD_PATH
                        where to store downloaded repositories
  --remote-time         try to set local timestamps of local files by the one
                        on the server
  --source              operate on source packages
  -u, --urls            Just list urls of what would be downloaded, don't
                        download

范例:创建局域网的基于Base的私有yum源

#仓库服务器配置
[root@repo-server ~]# yum -y install httpd

[root@repo-server ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

[root@repo-server ~]# mkdir /var/www/html/rocky/8 -pv
mkdir: created directory '/var/www/html/rocky'
mkdir: created directory '/var/www/html/rocky/8'

[root@repo-server ~]# mount /dev/sr0 /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.

[root@repo-server ~]# cp -a /mnt/* /var/www/html/rocky/8

#yum客户端配置
[root@repo-client ~]# cat /etc/yum.repos.d/test.repo
[BaseOS]
name=BaseOS
baseurl=http://172.31.1.8/rocky/8/BaseOS
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[AppStream]
name=Appstream
baseurl=http://172.31.1.8/rocky/8/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial

范例:下载阿里云的extras源,制作私有yum源

[root@repo-client ~]# yum makecache
BaseOS                                                                                                          79 MB/s | 2.5 MB     00:00    
Appstream                                                                                                      162 MB/s | 7.1 MB     00:00    
Last metadata expiration check: 0:00:01 ago on Thu 14 Oct 2021 01:10:58 AM CST.
Metadata cache created.

[root@repo-server ~]# dnf reposync --repoid=extras --download-metadata -p /var/www/html/rocky
[root@repo-server ~]# ls /var/www/html/rocky/
8  extras

[root@repo-server ~]# ls /var/www/html/rocky/extras/
Packages  repodata

[root@repo-client ~]# yum repolist
repo id                                                                 repo name
AppStream                                                               Appstream
BaseOS                                                                  BaseOS
[root@repo-client ~]# cat /etc/yum.repos.d/test.repo
[BaseOS]
name=BaseOS
baseurl=http://172.31.1.8/rocky/8/BaseOS
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[AppStream]
name=Appstream
baseurl=http://172.31.1.8/rocky/8/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial

[extras]
name=extras
baseurl=http://172.31.1.8/rocky/extras/

[root@repo-client ~]# yum repolist
repo id                                                                 repo name
AppStream                                                               Appstream
BaseOS                                                                  BaseOS
extras                                                                  extras

[root@repo-client ~]# yum --disablerepo=* --enablerepo=extras list available

[root@repo-client ~]# yum install epel-release

范例:下载阿里云的EPEL源,制作私有yum源

[root@repo-server ~]# cat /etc/yum.repos.d/epel.repo 
[EPEL]
name=EPEL
baseurl=https://mirrors.nju.edu.cn/epel/$releasever/Everything/$basearch/
gpgcheck=1
gpgkey=https://mirrors.nju.edu.cn/epel/RPM-GPG-KEY-EPEL-$releasever

[root@repo-server ~]# dnf repolist
repo id                                                            repo name
AppStream                                                          AppStream
BaseOS                                                             BaseOS
EPEL                                                               EPEL
PowerTools                                                         PowerTools
extras                                                             extras
plus                                                               plus

#下载相关仓库包和元数据
[root@repo-server ~]# dnf reposync --repoid=EPEL --download-metadata -p /var/www/html
#--download-metadata 加此选项可以下载元数据

#下载相关的key文件
[root@repo-server ~]# wget -P /var/www/html/epel/ https://mirrors.nju.edu.cn/epel/RPM-GPG-KEY-EPEL-8
#下面两个步骤只有没meta数据才需要执行
#[root@repo-server ~]# dnf -y install createrepo httpd
#[root@repo-server ~]# createrepo /var/www/html/epel/
[root@repo-server ~]# ls /var/www/html/EPEL
Packages  repodata

[root@repo-client ~]# vim /etc/yum.repos.d/test.repo 
[BaseOS]
name=BaseOS
baseurl=http://172.31.1.8/rocky/8/BaseOS
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
[AppStream]
name=Appstream
baseurl=http://172.31.1.8/rocky/8/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial

[extras]
name=extras
baseurl=http://172.31.1.8/rocky/extras/

[epel]
name=epel
baseurl=http://172.31.1.8/EPEL/
gpgkey=http://172.31.1.8/EPEL/RPM-GPG-KEY-EPEL-8

[root@repo-client ~]# yum makecache
BaseOS                                                                                               543 kB/s | 3.9 kB     00:00    
Appstream                                                                                            1.8 MB/s | 4.3 kB     00:00    
extras                                                                                               1.1 MB/s | 3.5 kB     00:00    
epel                                                                                                 123 MB/s |  10 MB     00:00    
Metadata cache created.

[root@repo-client ~]# dnf install openvpn

4.3.12 DNF 介绍

DNF,即DaNdiFied,是新一代的RPM软件包管理器。DNF 发行日期是2015年5月11日,DNF 包管理器采用Python 编写,发行许可为GPL v2,首先出现在Fedora 18 发行版中。在 RHEL 8.0 版本正式取代了 YUM,DNF包管理器克服了YUM包管理器的一些瓶颈,提升了包括用户体验,内存占用,依赖分析,运行速度等

配置文件:

/etc/dnf/dnf.conf

仓库文件:

/etc/yum.repos.d/ *.repo

日志:

/var/log/dnf.rpm.log
/var/log/dnf.log

DNF 使用帮助:man dnf

dnf 用法与yum一致

dnf [options] <command> [<arguments>...]
dnf --version
dnf repolist
dnf reposync
dnf install httpd
dnf remove httpd
dnf clean all
dnf makecache
dnf list installed
dnf list available
dnf search nano
dnf history undo 1

CentOS 7 使用 dnf ,下载并安装下面包

wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/dnf-conf-0.6.4-2.sdl7.noarch.rpm
wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/dnf-0.6.4-2.sdl7.noarch.rpm
wget http://springdale.math.ias.edu/data/puias/unsupported/7/x86_64/python-dnf-0.6.4-2.sdl7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/extras/x86_64/Packages/python2-libcomps-0.1.8-12.el7.x86_64.rpm
wget https://mirrors.aliyun.com/centos/7/extras/x86_64/Packages/libcomps-0.1.8-12.el7.x86_64.rpm

4.3.13 yum Troubleshooting

yum 和 dnf 失败最主要原因:

  • yum的配置文件格式或路径错误
    解决方法:检查/etc/yum.repos.d/*.repo文件格式

  • yum cache
    解决方法:yum clean all

  • 网络不通:

    解决方法:网卡配置

5.程序包编译

5.1 源码编译介绍

程序包编译安装:

源代码–>预处理–>编译–>汇编–>链接–>执行

多文件:文件中的代码之间,很可能存在跨文件依赖关系

虽然有很多开源软件将软件打成包,供人们使用,但并不是所有源代码都打成包,如果想使用开源软件,可能需要自已下载源码,进行编译安装。另外即使提供了包,但是生产中需要用于软件的某些特性,仍然需要自行编译安装。但是利用源代码编译安装是比较繁琐的,庆幸的是有相关的项目管理工具可以大大减少编译过程的复杂度

5.2 开源程序源代码的获取

项目官方自建站点:

​ apache.org (ASF:Apache Software Foundation)

​ mariadb.org

代码托管:
Github.com
gitee.com
SourceForge.net
code.google.com

5.3 编译源码的项目工具

  • C、C++的源码编译:使用 make 项目管理器
    configure脚本 --> Makefile.in --> Makefile
    相关开发工具:
    autoconf: 生成configure脚本
    automake:生成Makefile.in
  • java的源码编译: 使用 maven

5.4 C 语言源代码编译安装过程

利用编译工具,通常只需要三个大的步骤

  • ./configure
    (1) 通过选项传递参数,指定安装路径、启用特性等;执行时会参考用户的指定以及Makefile.in文
    件生成Makefile
    (2) 检查依赖到的外部环境,如依赖的软件包
  • make 根据Makefile文件,会检测依赖的环境,进行构建应用程序
  • make install 复制文件到相应路径

注意:安装前可以通过查看README,INSTALL获取帮助

5.4.1 编译安装准备

准备:安装相关的依赖包

  • 开发工具:make, gcc (c/c++编译器GNU C Complier)
  • 开发环境:开发库(glibc:标准库),头文件,可安装开发包组 Development Tools
  • 软件相关依赖包

生产实践:基于最小化安装的系统建议安装下面相关包

yum -y install  gcc make autoconf gcc-c++ glibc glibc-devel pcre pcre-devel openssl  openssl-devel systemd-devel zlib-devel  vim lrzsz tree  tmux  lsof tcpdump wget  net-tools iotop bc  bzip2 zip unzip nfs-utils man-pages

5.4.2 编译安装

第一步:运行 configure 脚本,生成Makefile 文件

其选项主要功能:

  • 可以指定安装位置
  • 指定启用的特性

获取其支持使用的选项

./configure --help

选项分类:

  • 安装路径设定:
    –prefix=/PATH:指定默认安装位置,默认为/usr/local/
    –sysconfdir=/PATH:配置文件安装位置
    System types:支持交叉编译
  • 软件特性和相关指定:
    Optional Features: 可选特性
    –disable-FEATURE
    –enable-FEATURE[=ARG]
    Optional Packages: 可选包
    –with-PACKAGE[=ARG] 依赖包
    –without-PACKAGE 禁用依赖关系

注意:通常被编译操作依赖的程序包,需要安装此程序包的“开发”组件,其包名一般类似于namedevel-VERSION

第二步:make

第三步:make install

5.4.3 安装后的配置

  1. 二进制程序目录导入至PATH环境变量中
    编辑文件/etc/profile.d/NAME.sh
export PATH=/PATH/TO/BIN:$PATH
  1. 相关用户及文件
    有些开源软件编译完成后,还需要创建相关的用户及文件

5.4.4 编译安装实战案例

5.4.4.1 官网下载并编译安装新版 tree

http://mama.indstate.edu/users/ice/tree/

范例:CentOS 7 编译安装 tree1.8

#下载源码并解压
[root@centos7 ~]# wget http://mama.indstate.edu/users/ice/tree/src/tree-1.8.0.tgz -P /usr/local/src

[root@centos7 ~]# cd /usr/local/src/
[root@centos7 src]# tar xf tree-1.8.0.tgz 
[root@centos7 src]# cd tree-1.8.0
[root@centos7 tree-1.8.0]# ls
CHANGES  color.c  doc  file.c  hash.c  html.c  INSTALL  json.c  LICENSE  Makefile  README  strverscmp.c  TODO  tree.c  tree.h  unix.c  xml.c

[root@centos7 tree-1.8.0]# vim Makefile
#修改这项,安装目录
prefix = /apps/tree

#修改版本
[root@centos7 tree-1.8.0]# grep "1.8.0" tree.c
static char *version ="$Version: $ tree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro $";
static char *hversion="\t\t tree v1.8.0 %s 1996 - 2018 by Steve Baker and Thomas Moore <br>\n"
[root@centos7 tree-1.8.0]#  sed -i 's#v1\.8\.0#v8.8.8#' tree.c
[root@centos7 tree-1.8.0]# grep "1.8.0" tree.c
[root@centos7 tree-1.8.0]# grep "8.8.8" tree.c
static char *version ="$Version: $ tree v8.8.8 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro $";
static char *hversion="\t\t tree v8.8.8 %s 1996 - 2018 by Steve Baker and Thomas Moore <br>\n"

[root@centos7 tree-1.8.0]# make
gcc -ggdb -pedantic -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o tree.o tree.c
make: gcc: Command not found
make: *** [tree.o] Error 127
#提示没有安装gcc

[root@centos7 tree-1.8.0]# yum -y install gcc

[root@centos7 tree-1.8.0]# make -j 2

[root@centos7 tree-1.8.0]# make install
install -d /apps/tree/bin
install -d /apps/tree/man/man1
if [ -e tree ]; then \
	install tree /apps/tree/bin/tree; \
fi
install doc/tree.1 /apps/tree/man/man1/tree.1

[root@centos7 tree-1.8.0]# tree
-bash: tree: command not found

[root@centos7 tree-1.8.0]# echo 'PATH=/apps/tree/bin:$PATH' > /etc/profile.d/tree.sh
[root@centos7 tree-1.8.0]# . /etc/profile.d/tree.sh 
[root@centos7 tree-1.8.0]# tree
.
├── CHANGES
├── color.c
├── color.o
├── doc
│   ├── tree.1
│   ├── tree.1.fr
│   └── xml.dtd
├── file.c
├── file.o
├── hash.c
├── hash.o
├── html.c
├── html.o
├── INSTALL
├── json.c
├── json.o
├── LICENSE
├── Makefile
├── README
├── strverscmp.c
├── TODO
├── tree
├── tree.c
├── tree.h
├── tree.o
├── unix.c
├── unix.o
├── xml.c
└── xml.o

1 directory, 28 files

[root@centos7 tree-1.8.0]# tree --version
tree v8.8.8 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro 

[root@centos7 tree-1.8.0]# man tree

[root@centos7 tree-1.8.0]# tree /apps/tree/
/apps/tree/
├── bin
│   └── tree
└── man
    └── man1
        └── tree.1

3 directories, 2 files

5.4.4.2 编译安装 cmatrix

https://github.com/abishekvashok/cmatrix

范例:CentOS 8 编译安装 cmatrix

[root@rocky8 ~]# wget https://github.com/abishekvashok/cmatrix/releases/download/v2.0/cmatrix-v2.0-Butterscotch.tar -P /usr/local/src

[root@rocky8 ~]# cd /usr/local/src/
[root@rocky8 src]# ls
cmatrix-v2.0-Butterscotch.tar
[root@rocky8 src]# tar xf cmatrix-v2.0-Butterscotch.tar 
[root@rocky8 src]# cd cmatrix
[root@rocky8 cmatrix]# ls
aclocal.m4      cmatrix       cmatrix.spec.in     config.h.in~   CONTRIBUTING.md  install-sh         matrix.fnt     README
AUTHORS         cmatrix.1     CODE_OF_CONDUCT.md  config.log     COPYING          ISSUE_TEMPLATE.md  matrix.psf.gz  README.md
autom4te.cache  cmatrix.c     compile             config.status  data             Makefile           missing        stamp-h1
ChangeLog       cmatrix.o     config.h            configure      depcomp          Makefile.am        mtx.pcf        takeScreenshots
CMakeLists.txt  cmatrix.spec  config.h.in         configure.ac   INSTALL          Makefile.in        NEWS

[root@rocky8 cmatrix]# ./configure --prefix=/apps/cmatrix
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/cmatrix':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
#提示没有安装gcc

[root@rocky8 cmatrix]# dnf -y install gcc

[root@rocky8 cmatrix]# ./configure --prefix=/apps/cmatrix

[root@rocky8 cmatrix]# make
(CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /usr/local/src/cmatrix/missing autoheader)
/usr/local/src/cmatrix/missing: line 81: autoheader: command not found
WARNING: 'autoheader' is missing on your system.
         You should only need it if you modified 'acconfig.h' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'autoheader' program is part of the GNU Autoconf package:
         <https://www.gnu.org/software/autoconf/>
         It also requires GNU m4 and Perl in order to run:
         <https://www.gnu.org/software/m4/>
         <https://www.perl.org/>
make: *** [Makefile:363: config.h.in] Error 127
#autoheader  提示没有装这个包

[root@rocky8 cmatrix]# dnf provides autoheader
Last metadata expiration check: 0:08:19 ago on Thu 14 Oct 2021 03:56:52 PM CST.
autoconf-2.69-27.el8.noarch : A GNU tool for automatically configuring source code
Repo        : AppStream
Matched from:
Filename    : /usr/bin/autoheader

[root@rocky8 cmatrix]# dnf -y install autoconf

[root@rocky8 cmatrix]# make
(CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /usr/local/src/cmatrix/missing autoheader)
rm -f stamp-h1
touch config.h.in
cd . && /bin/sh ./config.status config.h
config.status: creating config.h
config.status: config.h is unchanged
make  all-am
make[1]: Entering directory '/usr/local/src/cmatrix'
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT cmatrix.o -MD -MP -MF .deps/cmatrix.Tpo -c -o cmatrix.o cmatrix.c
cmatrix.c:43:10: fatal error: curses.h: No such file or directory
 #include <curses.h>
          ^~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:433: cmatrix.o] Error 1
make[1]: Leaving directory '/usr/local/src/cmatrix'
make: *** [Makefile:317: all] Error 2
# curses.h  提示没有这个文件

[root@rocky8 cmatrix]# dnf provides *curses.h*
...
ncurses-devel-6.1-7.20180224.el8.1.i686 : Development files for the ncurses library
Repo        : BaseOS
Matched from:
Other       : *curses.h*

ncurses-devel-6.1-7.20180224.el8.1.x86_64 : Development files for the ncurses library
Repo        : BaseOS
Matched from:
Other       : *curses.h*

notcurses-devel-2.4.3-2.el8.x86_64 : Development files for the Notcurses library
Repo        : EPEL
Matched from:
Other       : *curses.h*

[root@rocky8 cmatrix]# dnf -y install ncurses-devel

[root@rocky8 cmatrix]# make
...
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:416: cmatrix] Error 1
make[1]: Leaving directory '/usr/local/src/cmatrix'
make: *** [Makefile:317: all] Error 2
#出现这种错误,可能是先configure  再make,把文件删了 重新configure

[root@rocky8 cmatrix]# cd ..
[root@rocky8 src]# rm -rf cmatrix
[root@rocky8 src]# tar xf cmatrix-v2.0-Butterscotch.tar 
[root@rocky8 src]# cd cmatrix

[root@rocky8 cmatrix]# ./configure --prefix=/apps/cmatrix
[root@rocky8 cmatrix]# make -j 2
[root@rocky8 cmatrix]# make install
make[1]: Entering directory '/usr/local/src/cmatrix'
 /usr/bin/mkdir -p '/apps/cmatrix/bin'
  /usr/bin/install -c cmatrix '/apps/cmatrix/bin'
 Installing matrix fonts in /usr/lib/kbd/consolefonts...
 /usr/bin/mkdir -p '/apps/cmatrix/share/man/man1'
 /usr/bin/install -c -m 644 cmatrix.1 '/apps/cmatrix/share/man/man1'
make[1]: Leaving directory '/usr/local/src/cmatrix'
#安装完成

[root@rocky8 cmatrix]# tree /apps/cmatrix/
/apps/cmatrix/
├── bin
│   └── cmatrix
└── share
    └── man
        └── man1
            └── cmatrix.1

4 directories, 2 files

[root@rocky8 cmatrix]# echo 'PATH=/apps/cmatrix/bin/:$PATH' > /etc/profile.d/cmatrix.sh
[root@rocky8 cmatrix]# . /etc/profile.d/cmatrix.sh

[root@rocky8 cmatrix]# cmatrix

[root@rocky8 cmatrix]# cmatrix --help
 Usage: cmatrix -[abBcfhlsmVx] [-u delay] [-C color]
 -a: Asynchronous scroll
 -b: Bold characters on
 -B: All bold characters (overrides -b)
 -c: Use Japanese characters as seen in the original matrix. Requires appropriate fonts
 -f: Force the linux $TERM type to be on
 -l: Linux mode (uses matrix console font)
 -L: Lock mode (can be closed from another terminal)
 -o: Use old-style scrolling
 -h: Print usage and exit
 -n: No bold characters (overrides -b and -B, default)
 -s: "Screensaver" mode, exits on first keystroke
 -x: X window mode, use if your xterm is using mtx.pcf
 -V: Print version information and exit
 -u delay (0 - 10, default 4): Screen update delay
 -C [color]: Use this color for matrix (default green)
 -r: rainbow mode
 -m: lambda mode

[root@rocky8 cmatrix]# cmatrix -C red
#设置颜色

[root@rocky8 cmatrix]# cmatrix -r

5.4.4.3 编译安装 httpd 2.4

http://httpd.apache.org/

范例:centos8 编译安装 httpd-2.4.51

[root@rocky8 ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.51.tar.gz -P /usr/local/src

[root@rocky8 src]# tar xf httpd-2.4.51.tar.gz 

[root@rocky8 src]# cd httpd-2.4.51

[root@rocky8 httpd-2.4.51]# cat README
#README  告诉你软件怎么用的

[root@rocky8 httpd-2.4.51]# cat INSTALL
#INSTALL  安装方法

[root@rocky8 httpd-2.4.51]# ./configure --prefix=/apps/httpd --enable-ssl
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... no
configure: error: APR not found.  Please read the documentation.
#提示缺失 APR

[root@rocky8 httpd-2.4.51]# dnf -y install apr-devel
[root@rocky8 httpd-2.4.51]# ./configure --prefix=/apps/httpd --enable-ssl
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.
#提示缺少 APR-util

[root@rocky8 httpd-2.4.51]# dnf -y install apr-util-devel
[root@rocky8 httpd-2.4.51]# ./configure --prefix=/apps/httpd --enable-ssl
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to "  -pthread"
  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... none needed
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
#提示缺少 PCRE

[root@rocky8 httpd-2.4.51]# dnf -y install pcre-devel

[root@rocky8 httpd-2.4.51]# ./configure --prefix=/apps/httpd --enable-ssl
...
checking whether to enable mod_slotmem_plain... no
checking whether to enable mod_ssl... checking dependencies
checking for OpenSSL... checking for user-provided OpenSSL base directory... none
checking for OpenSSL version >= 0.9.8a... FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
#提示缺少 mod-ssl,这就是openssl

[root@rocky8 httpd-2.4.51]# dnf -y install openssl-devel

[root@rocky8 httpd-2.4.51]# ./configure --prefix=/apps/httpd --enable-ssl
[root@rocky8 httpd-2.4.51]# make -j 2 && make install
...
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
make[4]: *** [/usr/local/src/httpd-2.4.51/modules/aaa/modules.mk:2: mod_authn_file.la] Error 1
make[4]: *** Waiting for unfinished jobs....
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-ld: No such file or directory
make[4]: *** [/usr/local/src/httpd-2.4.51/modules/aaa/modules.mk:4: mod_authn_dbm.la] Error 1
make[4]: Leaving directory '/usr/local/src/httpd-2.4.51/modules/aaa'
make[3]: *** [/usr/local/src/httpd-2.4.51/build/rules.mk:117: shared-build-recursive] Error 1
make[3]: Leaving directory '/usr/local/src/httpd-2.4.51/modules/aaa'
make[2]: *** [/usr/local/src/httpd-2.4.51/build/rules.mk:117: shared-build-recursive] Error 1
make[2]: Leaving directory '/usr/local/src/httpd-2.4.51/modules'
make[1]: *** [/usr/local/src/httpd-2.4.51/build/rules.mk:117: shared-build-recursive] Error 1
make[1]: Leaving directory '/usr/local/src/httpd-2.4.51'
make: *** [/usr/local/src/httpd-2.4.51/build/rules.mk:75: all-recursive] Error 1
#提示 缺少redhat/redhat-hardened-ld文件

[root@rocky8 httpd-2.4.51]# yum provides *redhat-hardened-ld*
Last metadata expiration check: 0:08:25 ago on Thu 14 Oct 2021 04:26:51 PM CST.
redhat-rpm-config-125-1.el8.noarch : Rocky specific rpm configuration files
Repo        : AppStream
Matched from:
Other       : *redhat-hardened-ld*

[root@rocky8 httpd-2.4.51]# dnf -y install redhat-rpm-config
[root@rocky8 httpd-2.4.51]# make -j 2 && make install
[root@rocky8 httpd-2.4.51]# /apps/httpd/bin/apachectl start #启动程序
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fef9:6ad1. Set the 'ServerName' directive globally to suppress this message
[root@rocky8 httpd-2.4.51]# ss -ntl
State           Recv-Q           Send-Q                     Local Address:Port                     Peer Address:Port          Process          
LISTEN          0                128                              0.0.0.0:22                            0.0.0.0:*                              
LISTEN          0                128                                    *:80                                  *:*                              
LISTEN          0                128                                 [::]:22                               [::]:*  

在这里插入图片描述

[root@rocky8 httpd-2.4.51]# echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[root@rocky8 httpd-2.4.51]# . /etc/profile.d/httpd.sh
[root@rocky8 httpd-2.4.51]# apachectl stop #关闭服务
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fef9:6ad1. Set the 'ServerName' directive globally to suppress this message
[root@rocky8 httpd-2.4.51]# apachectl #启动服务
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fef9:6ad1. Set the 'ServerName' directive globally to suppress this message

[root@rocky8 httpd-2.4.51]# ps aux |grep httpd
root       46550  0.0  0.6 119012  5420 ?        Ss   16:42   0:00 /apps/httpd/bin/httpd
daemon     46551  0.0  0.9 880884  7636 ?        Sl   16:42   0:00 /apps/httpd/bin/httpd
daemon     46552  0.0  0.9 880884  7636 ?        Sl   16:42   0:00 /apps/httpd/bin/httpd
daemon     46553  0.0  0.9 880884  7636 ?        Sl   16:42   0:00 /apps/httpd/bin/httpd
root       46636  0.0  0.1  12136  1172 pts/0    R+   16:42   0:00 grep --color=auto httpd
#程序还以daemon 身份运行

[root@rocky8 httpd-2.4.51]# useradd -r -s /sbin/nologin apache
[root@rocky8 httpd-2.4.51]# vim /apps/httpd/conf/httpd.conf 
#把下面两行
User daemon   
Group daemon
#改成下面内容
User apache
Group apache 

[root@rocky8 httpd-2.4.51]# apachectl restart #重新启动服务
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fef9:6ad1. Set the 'ServerName' directive globally to suppress this message
#提示ServerName没修改

[root@rocky8 httpd-2.4.51]# vim /apps/httpd/conf/httpd.conf
ServerName 172.31.1.8:80 

[root@rocky8 httpd-2.4.51]# apachectl restart
#现在就没提示了

[root@rocky8 httpd-2.4.51]# ps aux |grep httpd
root       46550  0.0  0.7 119012  5788 ?        Ss   16:42   0:00 /apps/httpd/bin/httpd
apache     47174  0.0  0.9 880884  7272 ?        Sl   16:46   0:00 /apps/httpd/bin/httpd
apache     47175  0.0  0.9 880884  7272 ?        Sl   16:46   0:00 /apps/httpd/bin/httpd
apache     47176  0.0  0.9 880884  7272 ?        Sl   16:46   0:00 /apps/httpd/bin/httpd
root       47259  0.0  0.1  12136  1160 pts/0    R+   16:47   0:00 grep --color=auto httpd

root@ubuntu1804:~# apt -y install apache2
#ubuntu  上软件包是apache2

标签:httpd,cmatrix,--,tree,29,第八章,...,软件包,root
来源: https://blog.csdn.net/qq_25599925/article/details/120818578

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有