linux下源码安装apache环境

本文提供了一步一步的指导,教你如何在Linux系统上卸载自带的httpd服务,并安装Apache 2.2.23和2.4.3版本。包括解决安装过程中遇到的apr、apr-util及pcre依赖问题。

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


1、检查是否已经安装
[root@d ~]# rpm -qa | grep httpd
system-config-httpd-1.3.3.1-1.el5
httpd-manual-2.2.3-6.el5

2、停止并卸载Linux系统自带的httpd服务
[root@d ~]# service httpd stop
[root@d ~]# ps -ef | grep httpd
[root@d ~]# kill -9 pid号(逐个删除)
[root@d ~]# rpm -e system-config-httpd-1.3.3.1-1.el5
[root@d ~]# rpm -e httpd-manual-2.2.3-6.el5
查找一下apache的配置文件是否存在,存在就删除
[root@d ~]# find / -name httpd.conf


3、下载Apache安装包(httpd-2.4.3.tar.gz或httpd-2.2.23.tar.gz),下载地址:http://httpd.apache.org/
在安装Apache时,我分别针对不同版本进行了安装,在编译时是不同的,configure后跟的参数不同。
httpd-2.2.23版本编译命令:
[root@d ~]# ./configure --prefix=/usr/local/apache2 (安装目录参数后面可以不加任何参数,直接安装即可)
[root@d ~]# make
[root@d ~]# make install
httpd-2.4.3版本编译命令:
[root@d ~]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre 
(除了指定Apache的安装目录外,还要安装apr、apr-util、pcre,并指定参数)
[root@d ~]# make
[root@d ~]# make install
在编译Apache(在安装httpd-2.4.3时遇到的问题)时分别出现了apr not found、APR-util not found、pcre-config for libpcre not found的问题,
下面就httpd-2.4.3的这些问题解决来实际操作一把。
http://apr.apache.org/download.cgi 下载apr-1.4.5.tar.gz、apr-util-1.3.12.tar.gz
http://sourceforge.net/projects/pcre/files/latest/download 下载pcre-8.31.zip
A.解决apr not found问题
  [root@localhost bin]# tar -zxf apr-1.4.5.tar.gz
  [root@localhost apr-1.4.5]# ./configure --prefix=/usr/local/apr
  [root@localhost apr-1.4.5]# make
  [root@localhost apr-1.4.5]# make install
B.解决APR-util not found问题
  [root@localhost bin]# tar -zxf apr-util-1.3.12.tar.gz
  [root@localhost apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
  [root@localhost apr-util-1.3.12]# make
  [root@localhost apr-util-1.3.12]# make install
C、解决pcre-config for libpcre not found问题
  [root@localhost ~]# unzip pcre-8.31.zip
  [root@localhost ~]# cd pcre-8.31
  [root@localhost pcre-8.31]# ./configure --prefix=/usr/local/pcre
  [root@localhost pcre-8.31]# make
  [root@localhost pcre-8.31]# make install


如果已经存在/etc/httpd/httpd.conf,请先卸载或者关闭linux系统自带的web服务,执行命令:chkconfig  httpd off,
再或者把linux自带的httpd服务的80端口改为其他端口,只要不与我们安装的Apache服务的端口冲突就可以啦。
启动Apache:/usr/local/apache2/bin/apachectl start
停止Apache:/usr/local/apache2/bin/apachectl stop
重启Apache:/usr/local/apache2/bin/apachectl restart


网站放在/usr/local/apache2/htdocs目录下
在浏览器中通过http://localhost:80,如果看到页面中显示“It works!”字样,则代表Apache验证通过。如果网站的index后缀是jsp格式的,
则要修改httpd.conf配置文件(/usr/local/apache2/conf),在DirectoryIndex增加 index.jsp。
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
<IfModule dir_module>
    DirectoryIndex index.html index.php

</IfModule>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

BUG弄潮儿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值