apache源码安装

本文提供了一份详细的指南,介绍了如何从源码安装Apache及其依赖组件apr和apr-util,并配置Apache使其能够正常启动和服务。同时,文章还介绍了如何解决安装过程中遇到的一些常见问题。

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

1.apr和apr-util,下载地址: http://apr.apache.org/download.cgi

yum install gcc
yum install libtool
yum install expat-devel
yum install pcre-devel

cd apr-1.6.3/
./configure --prefix=/opt/apr

出现以下错误

rm: cannot remove 'libtoolT': No such file or directory

include/arch/unix/apr_private.h is unchange
cp configure ./configure.bak
vi configure
#$RM “$cfgfile”   #注释掉这行
:wq

!./configure --prefix #重新执行上一次相同的命令
make -j 4 #四核运行
make install

tar -zxvf apr-util-1.6.1.tar.bz2 #注意不要下载apr-util-1.6.1.tar.gz这个gz文件会出现安装错误
cd apr-util-1.6.1
./configure --prefix=/opt/apr-util --with-apr=/opt/apr
make && make instal

2. 下载安装pcre【如果以及yum安装则跳过此步】

wget https://ftp.pcre.org/pub/pcre/pcre2-10.30.tar.gz
tar -zxvf pcre2-10.30.tar.gz
cd pcre2-10.30
./configure --prefix=/opt/pcre
make && make installyum -y install pcre-devel

 3.安装apache

./configure --prefix=/opt/apache --with-apr=/opt/apr --with-apr-util=/opt/apr-util --with-include-apr --enable-so
make && make install

4.你会发现apache stop|restart|start都不成功

Could not reliably determine the server's fully qualified domain name

解决办法

vi httpd.conf
#ServerName www.example.com:80 
#修改为
ServerName localhost:80

5.将apache设定为开机启动

注册Apache到Linux服务
在Linux下用源代码方式编译安装完Apache后,启动关闭Apache可以通过如下命令实现:

/opt/apache/bin/apachectl start|stop|restart

加入开机启动

cp /opt/apache/bin/apachectl  /etc/rc.d/init.d/httpd 
#链接文件的S61是启动时的序号。
#当init.d目录下有httpd脚本后,我们就可以通过service命令来启动关闭apache了。
ln -s /etc/rc.d/init.d/httpd  /etc/rc.d/rc3.d/S61httpd
service httpd start | stop | restart

这时有个问题就是:虽然apache已经可以自动启动,但在linux的服务列表中却看不到它,要添加服务,一般通过chkconfig --add xxx来实现,但需要脚本中有相应的信息才行,否则chkconfig就会提示:xxx 服务不支持 chkconfig。所以我们首先编辑httpd脚本,在第2行(#!/bin/sh下面)添加如下注释信息(包括#):

vi /etc/rc.d/init.d/httpd
# chkconfig: 35 61 61
# description: Apache

第一行的3个参数意义分别为:在哪些运行级别启动httpd(3,5);启动序号(S61);关闭序号(K61)。注意:第二行的描述必须要写!保存后执行:

chkconfig --add httpd #所有开机模式下自启动,另外chkconfig httpd on 表示345模式下自启动

就将httpd添加入服务了。在rc3.d、rc5.d路径中将来就会出现S61httpd的链接,其他运行级别路径中会出现K61httpd的链接。

运行下面的命令查看服务,就可以看到httpd的服务了。

chkconfig --list

 

转载于:https://www.cnblogs.com/adtuu/p/8284408.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值