您的位置:首页 > 理论基础 > 计算机网络

编译安装httpd-2.2.31

2017-03-27 12:04 169 查看
一. 预备环境:
# 编译安装apache之前需要确认:apr(apache虚拟机),apr-util,apr-util-ldap的版本, 不同的版本所依赖的apr版本不同.
# httpd-2.2.*只需依赖于apr-1.3.9即可
# httpd-2.4.*需要依赖于apr-1.4.*或以上的版本
# 如需下载相应的版本: http://apr.apache.org/
# 查看apr的版本
[root@caiya ~]# rpm -qa apr*
apr-1.3.9-5.el6_2.i686
apr-util-ldap-1.3.9-3.el6_0.1.i686
apr-util-1.3.9-3.el6_0.1.i686
[root@caiya ~]#
# centos 6.X 版本自带的apr基本都是 apr-1.3.X, 满足httpd-2.2.x的要求. 直接安装即可

二. 安装apache(httpd)
# 下载httpd安装包(就近选择的下载地址, 搜狐镜像站点)
[root@caiya software]# wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz [root@caiya software]# tar zxvf httpd-2.2.31.tar.gz
[root@caiya software]# cd httpd-2.2.31

# httpd的模块解释:

# 指定安装路径
# --prefix=/usr/local/apache
# 指定配置文件的路径

# --sysconfdir=/etc/httpd
# 装载核心模块,支持动态共享模块,以模块的方式加载PHP, 如果不开启, 无法使用PHP
# --enable-so
# 支持URL重写
# --enable-rewrite
# 支持ssl的功能, 否则无法使用https
# --enable-ssl
# 启动压缩机会, 将文本信息压缩后回复给客户端, 浏览器自动解压, 很常用的一种压缩机制
# --enable-deflate

# 让PHP以FastCGI的模式工作, 必须要开启此项
# --enable-proxy-fcgi

# 配置

[root@caiya httpd-2.2.31]# ./configure \
--prefix=/usr/local/httpd-2.2.31 \
--sysconfdir=/etc/httpd \
--enable-so \
--enable-rewirte \
--enable-ssl \
--enable-cgi \
--enable-cgid \
--enable-modules=most \
--enable-mods-shared=most \
--enable-mpms-shared=all

# 如果报如下错误:

checking for pcre-config... false
configure: error: pcre-config for libpcre not found.
PCRE is required and available from http://pcre.org/
# 解决办法
[root@caiya httpd-2.2.31]# yum install pcre-devel -y
# 编译, 安装

[root@caiya httpd-2.2.31]# make
[root@caiya httpd-2.2.31]# make install
# 注意: httpd受selinux控制, 如果selinux为运行状态, 有可能导致httpd无法启动
# 此时为关闭状态, 如果不是关闭状态, 修改selinux配置文件 vim /etc/selinux/config 修改为: SELINUX=disabled
[root@caiya local]# getenforce
Disabled

[root@caiya local]#
# 至此apache已经安装完毕

三. 配置apache
# 启动apache
# 编译安装的启动脚本在: /usr/local/httpd-2.2.31/bin/apachectl
[root@caiya bin]# /usr/local/httpd-2.2.31/bin/apachectl start
# 如果报如下错误:
AH00557: httpd: apr_sockaddr_info_get() failed for caiya.localdomain
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1.
Set the 'ServerName' directive globally to suppress this message
# 解决办法:
[root@caiya httpd]# vim /etc/httpd/httpd.conf
找到"#ServerName www.example.com:80" 去掉前面的注释

# 检测是否正常启动(当前为正常状态)
[root@caiya bin]# /usr/local/httpd-2.2.31/bin/apachectl start
[root@caiya bin]# netstat -tnlp | grep 80
5:tcp 0 0 :::80 :::* LISTEN 41862/httpd
[root@caiya bin]# ps -ef | grep httpd
65:root 1397 1 0 15:14 ? 00:00:00 /usr/local/httpd-2.2.31/bin/httpd -k start
66:daemon 1398 1397 0 15:14 ? 00:00:00 /usr/local/httpd-2.2.31/bin/httpd -k start
67:daemon 1399 1397 0 15:14 ? 00:00:00 /usr/local/httpd-2.2.31/bin/httpd -k start
68:daemon 1400 1397 0 15:14 ? 00:00:00 /usr/local/httpd-2.2.31/bin/httpd -k start
69:daemon 1401 1397 0 15:14 ? 00:00:00 /usr/local/httpd-2.2.31/bin/httpd -k start
70:daemon 1402 1397 0 15:14 ? 00:00:00 /usr/local/httpd-2.2.31/bin/httpd -k start
71:daemon 1403 1397 0 15:14 ? 00:00:00 /usr/local/httpd-2.2.31/bin/httpd -k start
73:root 1405 1778 0 15:14 pts/1 00:00:00 grep --color -n httpd
[root@caiya bin]#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  httpd 编译安装