从source code编译成rpm包

本文介绍如何从源码包编译Apache httpd和OpenSSH为RPM包,包括创建源RPM、构建RPM、安装及配置服务器等步骤,并提供了在Red Hat系列系统上的具体操作指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 从.tar.bz2编译成rpm包

以httpd-2.4.46为例

从网上下载httpd-2.4.46.tar.bz2包

运行如下命令:

rpmbuild -tb httpd-2.4.46.tar.bz2

-ts是生成SRPM包

如果需要依赖包,请安装。

最后在rpmbuild的RPMS/x86_64目录中升级所需的rpm包

文档:http://httpd.apache.org/docs/trunk/platform/rpm.html

Using Apache With RPM Based Systems (Redhat / CentOS / Fedora)
Available Languages: en | fr

While many distributions make Apache httpd available as operating system supported packages, it can sometimes be desirable to install and use the canonical version of Apache httpd on these systems, replacing the natively provided versions of the packages.

While the Apache httpd project does not currently create binary RPMs for the various distributions out there, it is easy to build your own binary RPMs from the canonical Apache httpd tarball.

This document explains how to build, install, configure and run Apache httpd 2.4 under Unix systems supporting the RPM packaging format.

Creating a Source RPM
Building RPMs
Installing the Server
Configuring the Default Instance of Apache httpd
Configuring Additional Instances of Apache httpd on the Same Machine
See also
Comments
top
Creating a Source RPM
The Apache httpd source tarball can be converted into an SRPM as follows:

rpmbuild -ts httpd-2.4.x.tar.bz2

top
Building RPMs
RPMs can be built directly from the Apache httpd source tarballs using the following command:

rpmbuild -tb httpd-2.4.x.tar.bz2

Corresponding “-devel” packages will be required to be installed on your build system prior to building the RPMs, the rpmbuild command will automatically calculate what RPMs are required and will list any dependencies that are missing on your system. These “-devel” packages will not be required after the build is completed, and can be safely removed.

If successful, the following RPMs will be created:

httpd-2.4.x-1.i686.rpm
The core server and basic module set.
httpd-debuginfo-2.4.x-1.i686.rpm
Debugging symbols for the server and all modules.
httpd-devel-2.4.x-1.i686.rpm
Headers and development files for the server.
httpd-manual-2.4.x-1.i686.rpm
The webserver manual.
httpd-tools-2.4.x-1.i686.rpm
Supporting tools for the webserver.
mod_authnz_ldap-2.4.x-1.i686.rpm
mod_ldap and mod_authnz_ldap, with corresponding dependency on openldap.
mod_lua-2.4.x-1.i686.rpm
mod_lua module, with corresponding dependency on lua.
mod_proxy_html-2.4.x-1.i686.rpm
mod_proxy_html module, with corresponding dependency on libxml2.
mod_socache_dc-2.4.x-1.i686.rpm
mod_socache_dc module, with corresponding dependency on distcache.
mod_ssl-2.4.x-1.i686.rpm
mod_ssl module, with corresponding dependency on openssl.
top
Installing the Server
The httpd RPM is the only RPM necessary to get a basic server to run. Install it as follows:

rpm -U httpd-2.4.x-1.i686.rpm

Self contained modules are included with the server. Modules that depend on external libraries are provided as separate RPMs to install if needed.

top
Configuring the Default Instance of Apache httpd
The default configuration for the server is installed by default beneath the /etc/httpd directory, with logs written by default to /var/log/httpd. The environment for the webserver is set by default within the optional /etc/sysconfig/httpd file.

Start the server as follows:

service httpd restart

top
Configuring Additional Instances of Apache httpd on the Same Machine
It is possible to configure additional instances of the Apache httpd server running independently alongside each other on the same machine. These instances can have independent configurations, and can potentially run as separate users if so configured.

This was done by making the httpd startup script aware of its own name. This name is then used to find the environment file for the server, and in turn, the server root of the server instance.

To create an additional instance called httpd-additional, follow these steps:

Create a symbolic link to the startup script for the additional server:
ln -s /etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd-additional
chkconfig --add httpd-additional

Create an environment file for the server, using the /etc/sysconfig/httpd file as a template:

template from httpd

cp /etc/sysconfig/httpd /etc/sysconfig/httpd-additional

blank template

touch /etc/sysconfig/httpd-additional

Edit /etc/sysconfig/httpd-additional and pass the server root of the new server instance within the OPTIONS environment variable.
OPTIONS="-d /etc/httpd-additional -f conf/httpd-additional.conf"

Edit the server configuration file /etc/httpd-additional/conf/httpd-additional.conf to ensure the correct ports and paths are configured.
Start the server as follows:
service httpd-additional restart

Repeat this process as required for each server instance.

2 从tar.gz生成rpm

安装虚拟机:

virt-install --name=redhat65 --ram 8192 --vcpus=4 --disk path=/mydata/data2/vms/redhat65/redhat65.qcow2,size=20,format=qcow2,bus=virtio --location=/mydata/data2/rhel-server-6.5-x86_64-dvd.iso --network network=ovs-br0 --graphics=none --console=pty,target_type=serial --extra-args="console=tty0 console=ttyS0"

安装开发包:

yum groupinstall "Development Tools"

yum install rpm-build zlib-devel openssl-devel gcc perl-devel pam-devel unzip -y

mkdir rpmbuild

cd rpmbuild

mkdir BUILD

mkdir SPECS

mkdir RPMS

mkdir SOURCES

mkdir SRPMS

cp /root/openssh-8.4p1.tar.gz SOURCES/

cd /root/

tar zxvf openssh-8.4p1.tar.gz

cd openssh-8.4p1/contrib/redhat/

cp openssh.spec /root/rpmbuild/SPECS/

修改openssh.spec, 将no_gnome_askpass和no_x11_askpass都设置为1;


# Do we want to disable building of x11-askpass? (1=yes 0=no)
%global no_x11_askpass 1

# Do we want to disable building of gnome-askpass? (1=yes 0=no)
%global no_gnome_askpass 1

cd /root/rpmbuild/SPECS/

rpmbuild -bb openssh.spec

RPM包为生成在RPMS目录下。

升级

rpm -Uvh openssh-8.4p1-1.el6.x86_64.rpm openssh-server-8.4p1-1.el6.x86_64.rpm openssh-clients-8.4p1-1.el6.x86_64.rpm

修改/etc/ssh/sshd_config,将#PermitRootLogin prohibit-password修改为 PermitRootLogin yes

setenforce 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值