文章目錄
一、實驗環境
rpm包製作的實驗環境:
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.10 (Final)
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-754.el6.x86_64 #1 SMP Tue Jun 19 21:26:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# ifconfig | sed -rn 's/^[[:space:]]+inet addr:(.*)[[:space:]]+Bcast.*$/\1/p'
192.168.56.98
實驗安裝我們製作的rpm的環境:
[root@localhost opt]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@localhost opt]# uname -a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost opt]# ifconfig | sed -rn 's/^[[:space:]]+inet addr:(.*)[[:space:]]+Bcast.*$/\1/p'
192.168.56.96
二、去官網下載源代碼包
1、apache的apr項目的官方站點:
http://apr.apache.org/
2、apr、apr-util以及apr-iconv的源碼下載鏈接:
http://apr.apache.org/download.cgi
3、apache的httpd項目的官方站點
http://httpd.apache.org/
4、httpd2.4 的源碼下載鏈接:
http://httpd.apache.org/download.cgi#apache24
5、apr、apr-util以及apr-iconv和httpd的關係簡析:
參考摘抄鏈接:
https://www.cnblogs.com/Alight/p/3997777.html
apr:APR is the base portability library.
APR是一個基本的可一直運行庫。主要爲上層的應用程序提供一個可以跨越多操作系統平臺使用的
底層支持接口庫。在早期 的Apache版本中,應用程序本身必須能夠處理各種具體操作系統平臺的
細節,並針對不同的平臺調用不同的處理函數。隨着Apache的進一步開 發,Apache組織決定將這些
通用的函數獨立出來並發展成爲一個新的項目。
apr中包含了一些通用的開發組件,包括mmap,DSO等等。
apr-utils:APR-util provides a number of helpful abstractions on top of APR.
APR-util在ARP的基礎之上,抽象出來的。也是爲了輔助apache工作的。
APR-util提供的目錄中也是包含了一些常用的開發組件。這些組件與apr目錄下的相比,
它們與apache的關係更加密切一些。比如存儲段和存儲段組,加密等等。
apr-iconv:APR-iconv provides a portable iconv() implementation built on top of APR.
It is generally of interest only where no system provided iconv() is available (either in libiconv,
or libc as applicable). An example is the Windows platform, where APR-iconv is required to
enable the APR-util library's apr_xlate feature.
包中的文件主要用於實現iconv編碼。目前的大部分編碼轉換過程都是與本地編碼相關的。
在進行轉換之前必須能夠正確地設置本地編碼。因此假如兩個非本地編碼A和B需要轉換,
則轉換過程大致爲A->Local以及Local->B或者B->Local以及Local->A。
6、下載好的源代碼存放說明(要是bzip2壓縮格式的tar包)
[root@localhost ~]# cd /opt/
[root@localhost opt]# mkdir httpd_software #創建源代碼存放目錄
[root@localhost opt]# cd httpd_software/
[root@localhost httpd_software]# ls
[root@localhost httpd_software]# ls #上傳後再查看
apr-1.6.5.tar.bz2 apr-iconv-1.2.2.tar.bz2 apr-util-1.6.1.tar.bz2 httpd-2.4.37.tar.bz2
[root@localhost httpd_software]# file *.tar.bz2
apr-1.6.5.tar.bz2: bzip2 compressed data, block size = 900k
apr-iconv-1.2.2.tar.bz2: bzip2 compressed data, block size = 900k
apr-util-1.6.1.tar.bz2: bzip2 compressed data, block size = 900k
httpd-2.4.37.tar.bz2: bzip2 compressed data, block size = 900k
三、安裝開發包組
(1) CentOS 6.x安裝開發包組
安裝開發包組爲這兩個:"Development tools" "Server Platform Development"
(2) 查看要安裝的開發包組
yum groupinfo "Development tools"
yum groupinfo "Server Platform Development"
yum groupinfo "Server Platform"
上面省略一下內容......
Group: Development tools
Description: A basic development environment.
Mandatory Packages: #強制安裝的軟件包(開發包組安裝的化,默認這些必須要裝上)
autoconf
automake
binutils
bison
flex
gcc
gcc-c++
gettext
libtool
make
patch
pkgconfig
redhat-rpm-config
rpm-build
Default Packages: #默認軟件包
byacc
cscope
ctags
cvs
diffstat
doxygen
elfutils
gcc-gfortran
git
indent
intltool
patchutils
rcs
subversion
swig
systemtap
Optional Packages: #可選軟件包
ElectricFence
PyYAML
ant
babel
bzr
chrpath
cmake
compat-gcc-34
compat-gcc-34-c++
compat-gcc-34-g77
cvs-inetd
dejagnu
expect
gcc-gnat
gcc-java
gcc-objc
gcc-objc++
imake
jpackage-utils
kdewebdev
ksc
libstdc++-docs
mercurial
mod_dav_svn
nasm
perltidy
python-docs
python-requests
python-six
rpmdevtools
rpmlint
systemtap-sdt-devel
systemtap-server
[root@localhost httpd_software]# yum groupinfo "Server Platform Development"
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
Group: Server Platform Development
Description: Development headers and libraries for developing applications to run on the CentOS Linux Server Platform.
Mandatory Packages: #這個開發包組主要是一些庫的頭文件。(不全)
db4-devel
dbus-devel
glibc-devel
krb5-devel
libstdc++-devel
libvirt-devel
libvirt-java-devel
ncurses-devel
nss-devel
openldap-devel
openssl-devel
pam-devel
zlib-devel
[root@localhost ~]# yum groupinfo "Server Platform"
Loaded plugins: fastestmirror
Setting up Group Process
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirrors.163.com
* updates: mirrors.163.com
Group: Server Platform
Description: Supported libraries for the CentOS Linux Server Platform.
Mandatory Packages: #這個包組包括一些支持的庫
db4
dbus-libs
glibc
krb5-libs
libgcc
libstdc++
ncurses-libs
nss
openldap
openssl
pam
redhat-lsb
zlib
Optional Packages:
libatomic
libcilkrts
libitm
libmpx
彙總安裝爲:
yum groupinstall "Development tools" "Server Platform Development" "Server Platform"
配置epel源:(爲了讓安裝更快,我配置一個epel源)
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
安裝rpm製作相關的工具包:
yum install rpm-build rpmdevtools
安裝過程省略,因爲比較長,看懂上面的解釋後,直接安裝即可。
四、利用源代碼的tar.bz2格式的包製作rpm包
4.1、爲什麼製作rpm包說明
(1) rpmbuild命令的簡要幫助信息
[root@localhost httpd_software]# rpmbuild --help
Usage: rpmbuild [OPTION...]
--quiet
Build options with [ <specfile> | <tarball> | <source package> ]:
-bp build through %prep (unpack sources and apply patches) from <specfile>
-bc build through %build (%prep, then compile) from <specfile>
-bi build through %install (%prep, %build, then install) from <specfile>
-bl verify %files section from <specfile>
-ba build source and binary packages from <specfile>
-bb build binary package only from <specfile>
-bs build source package only from <specfile>
-tp build through %prep (unpack sources and apply patches) from <tarball>
-tc build through %build (%prep, then compile) from <tarball>
-ti build through %install (%prep, %build, then install) from <tarball>
-ta build source and binary packages from <tarball>
#這個是我們一會兒要用的選項。從tarball包中構建二進制包(rpm包)
-tb build binary package only from <tarball>
-ts build source package only from <tarball>
--rebuild build binary package from <source package>
--recompile build through %install (%prep, %build, then install) from <source package>
--buildroot=DIRECTORY override build root
--clean remove build tree when done
--nobuild do not execute any stages of the build
--nodeps do not verify build dependencies
--nodirtokens generate package header(s) compatible with (legacy) rpm[23] packaging
--rmsource remove sources when done
--rmspec remove specfile when done
--short-circuit skip straight to specified stage (only for c,i)
--target=CPU-VENDOR-OS override target platform
Common options for all rpm modes and executables:
-D, --define='MACRO EXPR' define MACRO with value EXPR
-E, --eval='EXPR' print macro expansion of EXPR
--macros=<FILE:...> read <FILE:...> instead of default file(s)
--nodigest don't verify package digest(s)
--nosignature don't verify package signature(s)
--rcfile=<FILE:...> read <FILE:...> instead of default file(s)
-r, --root=ROOT use ROOT as top level directory (default: "/")
--querytags display known query tags
--showrc display final rpmrc and macro configuration
--quiet provide less detailed output
-v, --verbose provide more detailed output
--version print the version of rpm being used
Options implemented via popt alias/exec:
--dbpath=DIRECTORY use database in DIRECTORY
--with=<option> enable configure <option> for build
--without=<option> disable configure <option> for build
--buildpolicy=<policy> set buildroot <policy> (e.g. compress man pages)
Help options:
-?, --help Show this help message
--usage Display brief usage message
#因爲從specfile製作語法過於複雜,我們這裏直接使用從tarball包中製作。
(2) 先測試一下httpd2.4版本的包製作需要的依賴有哪些
[root@localhost httpd_software]# rpmbuild -tb httpd-2.4.37.tar.bz2
error: Failed build dependencies:
libuuid-devel is needed by httpd-2.4.37-1.x86_64
apr-devel >= 1.4.0 is needed by httpd-2.4.37-1.x86_64
apr-util-devel >= 1.4.0 is needed by httpd-2.4.37-1.x86_64
pcre-devel >= 5.0 is needed by httpd-2.4.37-1.x86_64
lua-devel is needed by httpd-2.4.37-1.x86_64
libxml2-devel is needed by httpd-2.4.37-1.x86_64
構建httpd2.4版本的rpm包還需要:
libuuid-devel這個庫頭文件,apr-devel要大於等於1.4.0版本,apr-util-devel要大於等於1.4.0版本
pcre-devel要大於等於5.0版本,lua-devel這個庫頭文件,libxml2-devel這個庫頭文件。
我們來看看現在yum倉庫提供的這些軟件版本符合不符合:
[root@localhost httpd_software]# yum list |grep -E '^libuuid-devel|^apr-devel|^apr-util-devel|^pcre-devel|^lua-devel|^libxml2-devel'
apr-devel.i686 1.3.9-5.el6_9.1 base
apr-devel.x86_64 1.3.9-5.el6_9.1 base
apr-util-devel.i686 1.3.9-3.el6_0.1 base
apr-util-devel.x86_64 1.3.9-3.el6_0.1 base
libuuid-devel.i686 2.17.2-12.28.el6_9.2 base
libuuid-devel.x86_64 2.17.2-12.28.el6_9.2 base
libxml2-devel.i686 2.7.6-21.el6_8.1 base
libxml2-devel.x86_64 2.7.6-21.el6_8.1 base
lua-devel.i686 5.1.4-4.1.el6 base
lua-devel.x86_64 5.1.4-4.1.el6 base
pcre-devel.i686 7.8-7.el6 base
pcre-devel.x86_64 7.8-7.el6 base
結論:只有apr-devel和apr-util-devel版本不符合,而且這也是爲什麼CentOS6.x一直是httpd2.2的緣故,因爲
httpd2.4版本需要的是apr和apr-util版本要大於1.4.0,而base倉庫提供的是1.3.9版本的。
4.2、apr源代碼製作rpm包
(1) 先看看製作apr有什麼依賴問題沒有
[root@localhost httpd_software]# rpmbuild -tb apr-1.6.5.tar.bz2
error: Failed build dependencies:
libuuid-devel is needed by apr-1.6.5-1.x86_64
(2) 安裝libuuid-devel後再重新制作
yum install libuuid-devel
rpmbuild -tb apr-1.6.5.tar.bz2
製作如果沒有報錯,那麼RPM包默認路徑:(我是root用戶操作的,所以在家目錄下會創建rpmbuild目錄)
/root/rpmbuild/RPMS/x86_64
[root@localhost httpd_software]# ls /root/rpmbuild/RPMS/x86_64/
apr-1.6.5-1.x86_64.rpm apr-debuginfo-1.6.5-1.x86_64.rpm apr-devel-1.6.5-1.x86_64.rpm
#可以看到製作出了3個軟件包,生產中用的就是apr和apr-devel這兩個,可以看到apr-devel版本符合
大於等於1.4.0版本了。那個apr-debuginfo是與調試相關的,可以不用。
4.3、apr-util源代碼製作rpm包
(1) 先看看製作apr-util有什麼依賴問題沒有
[root@localhost httpd_software]# rpmbuild -tb apr-util-1.6.1.tar.bz2
error: Failed build dependencies:
apr-devel >= 1.4.0 is needed by apr-util-1.6.1-1.x86_64
expat-devel is needed by apr-util-1.6.1-1.x86_64
postgresql-devel is needed by apr-util-1.6.1-1.x86_64
mysql-devel is needed by apr-util-1.6.1-1.x86_64
sqlite-devel >= 3.0.0 is needed by apr-util-1.6.1-1.x86_64
unixODBC-devel is needed by apr-util-1.6.1-1.x86_64
#這裏依賴可多來,要先安裝我們之前製作好的大於等於1.4.0版本的apr-devel。
然後是一些庫頭文件,我們直接yum安裝即可,那個sqlite-devel,默認base倉庫版本符合。
yum install expat-devel postgresql-devel mysql-devel sqlite-devel unixODBC-devel
安裝我們之前製作的apr-devel的rpm包:
[root@localhost httpd_software]# rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-devel-1.6.5-1.x86_64.rpm
error: Failed dependencies:
apr = 1.6.5 is needed by apr-devel-1.6.5-1.x86_64
[root@localhost httpd_software]# rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-1.6.5-1.x86_64.rpm
Preparing... ########################################### [100%]
1:apr ########################################### [100%]
[root@localhost httpd_software]# rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-devel-1.6.5-1.x86_64.rpm
Preparing... ########################################### [100%]
1:apr-devel ########################################### [100%]
注意點1:我們要使用升級安裝,因爲可能系統存在低版本的apr和apr-devel(1.3.9版本的);
注意點2:我們在安裝自己製作的apr-devel的時候,要看看是否有依賴問題,apr-devel要依賴於apr,所以
要先安裝apr(要注意版本的對應)
檢測安裝後的版本:
[root@localhost httpd_software]# rpm -qa|grep apr
apr-util-1.3.9-3.el6_0.1.x86_64 #這個是base倉庫低版本的
apr-devel-1.6.5-1.x86_64 #這個符合
apr-1.6.5-1.x86_64 #這個符合
(2) 重新制作apr-util
rpmbuild -tb apr-util-1.6.1.tar.bz2
PS:過程比較長,就省略了
(3) 查看製作的rpm包
[root@localhost httpd_software]# ls -l /root/rpmbuild/RPMS/x86_64/
total 2520
-rw-r--r--. 1 root root 98824 Dec 1 17:45 apr-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 438508 Dec 1 17:45 apr-debuginfo-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 892132 Dec 1 17:45 apr-devel-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 83408 Dec 1 17:57 apr-util-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 7084 Dec 1 17:57 apr-util-dbm-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 446464 Dec 1 17:57 apr-util-debuginfo-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 490012 Dec 1 17:57 apr-util-devel-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 9024 Dec 1 17:57 apr-util-ldap-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 14912 Dec 1 17:57 apr-util-mysql-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 12420 Dec 1 17:57 apr-util-nss-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 20592 Dec 1 17:57 apr-util-odbc-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 10844 Dec 1 17:57 apr-util-openssl-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 14804 Dec 1 17:57 apr-util-pgsql-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 11360 Dec 1 17:57 apr-util-sqlite-1.6.1-1.x86_64.rpm
#可以看到與apr-util相關的子包很多。基本上都是數據庫的,有DBM驅動,LDAP,mysql驅動,還有 Mozilla NSS的加密方面的,ODBC驅動,PostgreSQL驅動,SQLite驅動,OpenSSL加密相關。
4.4、apr-iconv源代碼製作rpm包
(1) 先看看製作apr-iconv有什麼依賴問題沒有
[root@localhost httpd_software]# rpmbuild -tb apr-iconv-1.2.2.tar.bz2
error: Failed to read spec file from apr-iconv-1.2.2.tar.bz2
[root@localhost httpd_software]# rpmbuild -tb apr-iconv-1.2.2.tar.gz
error: Failed to read spec file from apr-iconv-1.2.2.tar.gz
#發現有報錯,然後沒找到spec文件,可能這個軟件包因爲不是安裝httpd2.4必須,所以沒有提供spec。
(2) 解壓開來看看與其他源代碼包的區別,順便看看說明文檔
[root@localhost httpd_software]# ls -l apr-1.6.5/*.spec
-rw-r--r--. 1 1001 1001 2558 Sep 11 05:14 apr-1.6.5/apr.spec
[root@localhost httpd_software]# ls -l apr-iconv-1.2.2/*.spec
ls: cannot access apr-iconv-1.2.2/*.spec: No such file or directory
#果然這個軟件包沒有提供spec文件,那麼我們就不管這個軟件包了。如果實在要,我們可以編譯
安裝。而且我們之前有檢測過,httpd2.4版本好像默認依賴包中不包含這個軟件包。
4.5、httpd源代碼製作rpm包
(1) 先看看製作httpd的rpm有什麼依賴問題沒有
[root@localhost httpd_software]# rpmbuild -tb httpd-2.4.37.tar.bz2
error: Failed build dependencies:
apr-util-devel >= 1.4.0 is needed by httpd-2.4.37-1.x86_64
pcre-devel >= 5.0 is needed by httpd-2.4.37-1.x86_64
lua-devel is needed by httpd-2.4.37-1.x86_64
libxml2-devel is needed by httpd-2.4.37-1.x86_64
(2) 解決依賴
yum install pcre-devel lua-devel libxml2-devel
拷貝與apr-util相關的所有包到一個目錄,利用yum包安裝所有的rpm後綴的,自動讓它解決依賴關係
[root@localhost httpd_software]# mkdir /tmp/apr-util-rpm
[root@localhost httpd_software]# cd /tmp/apr-util-rpm
[root@localhost apr-util-rpm]# cp -a /root/rpmbuild/RPMS/x86_64/apr-util-*.rpm .
[root@localhost apr-util-rpm]# ls
apr-util-1.6.1-1.x86_64.rpm apr-util-devel-1.6.1-1.x86_64.rpm apr-util-nss-1.6.1-1.x86_64.rpm apr-util-pgsql-1.6.1-1.x86_64.rpm
apr-util-dbm-1.6.1-1.x86_64.rpm apr-util-ldap-1.6.1-1.x86_64.rpm apr-util-odbc-1.6.1-1.x86_64.rpm apr-util-sqlite-1.6.1-1.x86_64.rpm
apr-util-debuginfo-1.6.1-1.x86_64.rpm apr-util-mysql-1.6.1-1.x86_64.rpm apr-util-openssl-1.6.1-1.x86_64.rpm
[root@localhost apr-util-rpm]# rm -f apr-util-debuginfo-1.6.1-1.x86_64.rpm #刪掉那個調試的包
[root@localhost apr-util-rpm]# yum install *.rpm
檢查:
[root@localhost apr-util-rpm]# rpm -qa|grep apr
apr-util-mysql-1.6.1-1.x86_64
apr-util-devel-1.6.1-1.x86_64
apr-util-nss-1.6.1-1.x86_64
apr-devel-1.6.5-1.x86_64
apr-util-1.6.1-1.x86_64
apr-util-ldap-1.6.1-1.x86_64
apr-util-openssl-1.6.1-1.x86_64
apr-util-dbm-1.6.1-1.x86_64
apr-util-sqlite-1.6.1-1.x86_64
apr-1.6.5-1.x86_64
apr-util-pgsql-1.6.1-1.x86_64
apr-util-odbc-1.6.1-1.x86_64
(3) 再次製作httpd2.4的rpm包
[root@localhost apr-util-rpm]# cd /opt/httpd_software/
[root@localhost httpd_software]# rpmbuild -tb httpd-2.4.37.tar.bz2
製作過程很長,省略了。
(4) rpm包查看
[root@localhost httpd_software]# ls -l /root/rpmbuild/RPMS/x86_64/
total 12212
-rw-r--r--. 1 root root 98824 Dec 1 17:45 apr-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 438508 Dec 1 17:45 apr-debuginfo-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 892132 Dec 1 17:45 apr-devel-1.6.5-1.x86_64.rpm
-rw-r--r--. 1 root root 83408 Dec 1 17:57 apr-util-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 7084 Dec 1 17:57 apr-util-dbm-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 446464 Dec 1 17:57 apr-util-debuginfo-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 490012 Dec 1 17:57 apr-util-devel-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 9024 Dec 1 17:57 apr-util-ldap-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 14912 Dec 1 17:57 apr-util-mysql-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 12420 Dec 1 17:57 apr-util-nss-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 20592 Dec 1 17:57 apr-util-odbc-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 10844 Dec 1 17:57 apr-util-openssl-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 14804 Dec 1 17:57 apr-util-pgsql-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 11360 Dec 1 17:57 apr-util-sqlite-1.6.1-1.x86_64.rpm
-rw-r--r--. 1 root root 1260500 Dec 1 18:19 httpd-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 3646060 Dec 1 18:19 httpd-debuginfo-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 199852 Dec 1 18:19 httpd-devel-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 4533472 Dec 1 18:19 httpd-manual-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 72248 Dec 1 18:19 httpd-tools-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 44660 Dec 1 18:19 mod_authnz_ldap-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 44076 Dec 1 18:19 mod_lua-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 22964 Dec 1 18:19 mod_proxy_html-2.4.37-1.x86_64.rpm
-rw-r--r--. 1 root root 89992 Dec 1 18:19 mod_ssl-2.4.37-1.x86_64.rpm
#上面可以看到有httpd相關的包了,還有mod相關的包
我們把這些rpm保存到一個預建的目錄,然後去掉不需要的調試相關的,打包好來以備後邊我們測試使用
[root@localhost httpd_software]# mkdir /var/tmp/http_all_rpms
[root@localhost httpd_software]# cd /var/tmp/http_all_rpms
[root@localhost http_all_rpms]# cp -a /root/rpmbuild/RPMS/x86_64/*.rpm .
[root@localhost http_all_rpms]# rm -f apr-debuginfo-1.6.5-1.x86_64.rpm apr-util-debuginfo-1.6.1-1.x86_64.rpm httpd-debuginfo-2.4.37-1.x86_64.rpm
[root@localhost http_all_rpms]# ls *.rpm
apr-1.6.5-1.x86_64.rpm apr-util-ldap-1.6.1-1.x86_64.rpm apr-util-pgsql-1.6.1-1.x86_64.rpm httpd-tools-2.4.37-1.x86_64.rpm
apr-devel-1.6.5-1.x86_64.rpm apr-util-mysql-1.6.1-1.x86_64.rpm apr-util-sqlite-1.6.1-1.x86_64.rpm mod_authnz_ldap-2.4.37-1.x86_64.rpm
apr-util-1.6.1-1.x86_64.rpm apr-util-nss-1.6.1-1.x86_64.rpm httpd-2.4.37-1.x86_64.rpm mod_lua-2.4.37-1.x86_64.rpm
apr-util-dbm-1.6.1-1.x86_64.rpm apr-util-odbc-1.6.1-1.x86_64.rpm httpd-devel-2.4.37-1.x86_64.rpm mod_proxy_html-2.4.37-1.x86_64.rpm
apr-util-devel-1.6.1-1.x86_64.rpm apr-util-openssl-1.6.1-1.x86_64.rpm httpd-manual-2.4.37-1.x86_64.rpm mod_ssl-2.4.37-1.x86_64.rpm
[root@localhost http_all_rpms]# cd ../
[root@localhost tmp]# tar -Jcvf http_all_rpms.tar.xz http_all_rpms/
http_all_rpms/
http_all_rpms/mod_lua-2.4.37-1.x86_64.rpm
http_all_rpms/mod_authnz_ldap-2.4.37-1.x86_64.rpm
http_all_rpms/apr-util-1.6.1-1.x86_64.rpm
http_all_rpms/httpd-tools-2.4.37-1.x86_64.rpm
http_all_rpms/mod_ssl-2.4.37-1.x86_64.rpm
http_all_rpms/apr-util-devel-1.6.1-1.x86_64.rpm
http_all_rpms/apr-1.6.5-1.x86_64.rpm
http_all_rpms/apr-util-nss-1.6.1-1.x86_64.rpm
http_all_rpms/httpd-2.4.37-1.x86_64.rpm
http_all_rpms/mod_proxy_html-2.4.37-1.x86_64.rpm
http_all_rpms/apr-util-ldap-1.6.1-1.x86_64.rpm
http_all_rpms/apr-util-dbm-1.6.1-1.x86_64.rpm
http_all_rpms/httpd-manual-2.4.37-1.x86_64.rpm
http_all_rpms/apr-devel-1.6.5-1.x86_64.rpm
http_all_rpms/apr-util-pgsql-1.6.1-1.x86_64.rpm
http_all_rpms/apr-util-sqlite-1.6.1-1.x86_64.rpm
http_all_rpms/apr-util-mysql-1.6.1-1.x86_64.rpm
http_all_rpms/httpd-devel-2.4.37-1.x86_64.rpm
http_all_rpms/apr-util-openssl-1.6.1-1.x86_64.rpm
http_all_rpms/apr-util-odbc-1.6.1-1.x86_64.rpm
[root@localhost tmp]# ls -l http_all_rpms.tar.xz
-rw-r--r--. 1 root root 7643536 Dec 1 18:22 http_all_rpms.tar.xz
4.6、選一臺最小化安裝的新服務使用我們製作的rpm包
[root@localhost opt]# ls
http_all_rpms http_all_rpms.tar.xz
[root@localhost opt]# ls -l http_all_rpms
total 7780
-rw-r--r-- 1 root root 98824 Dec 1 17:45 apr-1.6.5-1.x86_64.rpm
-rw-r--r-- 1 root root 892132 Dec 1 17:45 apr-devel-1.6.5-1.x86_64.rpm
-rw-r--r-- 1 root root 83408 Dec 1 17:57 apr-util-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 7084 Dec 1 17:57 apr-util-dbm-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 490012 Dec 1 17:57 apr-util-devel-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 9024 Dec 1 17:57 apr-util-ldap-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 14912 Dec 1 17:57 apr-util-mysql-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 12420 Dec 1 17:57 apr-util-nss-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 20592 Dec 1 17:57 apr-util-odbc-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 10844 Dec 1 17:57 apr-util-openssl-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 14804 Dec 1 17:57 apr-util-pgsql-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 11360 Dec 1 17:57 apr-util-sqlite-1.6.1-1.x86_64.rpm
-rw-r--r-- 1 root root 1260500 Dec 1 18:19 httpd-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 199852 Dec 1 18:19 httpd-devel-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 4533472 Dec 1 18:19 httpd-manual-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 72248 Dec 1 18:19 httpd-tools-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 44660 Dec 1 18:19 mod_authnz_ldap-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 44076 Dec 1 18:19 mod_lua-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 22964 Dec 1 18:19 mod_proxy_html-2.4.37-1.x86_64.rpm
-rw-r--r-- 1 root root 89992 Dec 1 18:19 mod_ssl-2.4.37-1.x86_64.rpm
[root@localhost opt]# pwd
/opt
[root@localhost opt]# cd http_all_rpms
[root@localhost http_all_rpms]# yum install *.rpm
安裝過程省略,查看安裝後的軟件包:
[root@localhost http_all_rpms]# rpm -qa|grep httpd
httpd-2.4.37-1.x86_64
httpd-manual-2.4.37-1.x86_64
httpd-tools-2.4.37-1.x86_64
httpd-devel-2.4.37-1.x86_64
[root@localhost http_all_rpms]# rpm -qa|grep apr
apr-util-mysql-1.6.1-1.x86_64
apr-util-dbm-1.6.1-1.x86_64
apr-util-nss-1.6.1-1.x86_64
apr-1.6.5-1.x86_64
apr-util-ldap-1.6.1-1.x86_64
apr-util-devel-1.6.1-1.x86_64
apr-util-odbc-1.6.1-1.x86_64
apr-util-sqlite-1.6.1-1.x86_64
apr-util-openssl-1.6.1-1.x86_64
apr-util-1.6.1-1.x86_64
apr-devel-1.6.5-1.x86_64
apr-util-pgsql-1.6.1-1.x86_64
#操作啓動httpd事宜,然後啓動,訪問測試
[root@localhost http_all_rpms]# id apache
uid=48(apache) gid=48(apache) groups=48(apache)
[root@localhost http_all_rpms]# chkconfig --list|grep httpd
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost http_all_rpms]# service httpd status
httpd is stopped
[root@localhost http_all_rpms]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost http_all_rpms]#
[root@localhost http_all_rpms]# service httpd configtest
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
Syntax OK
vim /etc/httpd/conf/httpd.conf
添加一行:
ServerName www.yanhui.com
向/etc/hosts中加入一條記錄:
[root@localhost http_all_rpms]# echo "192.168.56.96 www.yanhui.com" >> /etc/hosts
[root@localhost http_all_rpms]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.96 www.yanhui.com
[root@localhost http_all_rpms]# service httpd configtest
Syntax OK
[root@localhost http_all_rpms]# service httpd start
Starting httpd: [ OK ]
[root@localhost http_all_rpms]# ss -nltu
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp LISTEN 0 128 :::80 :::*
tcp LISTEN 0 128 :::22 :::*
tcp LISTEN 0 128 *:22 *:*
tcp LISTEN 0 100 ::1:25 :::*
tcp LISTEN 0 100 127.0.0.1:25 *:*
[root@localhost http_all_rpms]# ps aux|grep httpd
root 1396 0.0 0.2 78636 2236 ? Ss 18:53 0:00 /usr/sbin/httpd
daemon 1398 0.0 0.4 422896 4208 ? Sl 18:53 0:00 /usr/sbin/httpd
daemon 1426 0.0 0.4 422896 4212 ? Sl 18:53 0:00 /usr/sbin/httpd
daemon 1427 0.0 0.4 422896 4208 ? Sl 18:53 0:00 /usr/sbin/httpd
root 1488 0.0 0.0 103260 876 pts/0 S+ 18:53 0:00 grep httpd
訪問測試:
上面表示測試通過,日誌中也有這條訪問記錄。