centos7编译安装apache

在vm上编译安装了一下apache,vm环境是centos7。编译安装的apache版本是httpd-2.4.18。

编译与安装

编译安装采用“configure/make/make install”的方式进行。

./configure --prefix=/usr/local/apache2 --enable-so --enable-deflate --enable-expires --enable-rewrite --enable-cache --enable-file-cache --enable-mem-cache --disable-cgi --enable-static-support --with-mpm=worker  --enable-ssl --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-headers

配置参数

比较懒,以下配置参数有部份引自此博客

–prefix:指定安装的目录;
–enable-rewrite:启用URL重写支持;
–enable-so:启用DSO(Dynamic Shared Objects动态共享目标),这个通常是默认启用;
–enable-cache:启用缓存支持;
–enable-headers:提供对HTTP请求头的控制;
–enable-expires:激活通过配置文件控制HTTP的“Expires:”和“Cache-Control:”头内容,即对网站图片、js、css等内容,提供客户端浏览器缓存的设置。这个是apache调优的一个重要选项之一;
–with-mpm=worker:选择apache mpm的模式为worker模式。为worker模式原理是更多的使用线程来处理请求,所以可以处理更多的并发请求。而系统
资源的开销小于基于进程的MPM
prefork。如果不指定此参数,默认的模式是prefork进程模式(–with-mpm=MPM)。这个是apache调优的一个重要选项之一;
–enable-deflate:提供对内容的压缩传输编码支持,一般是html、js、css等内容的站点。使用此参数会打打提高传输速度,提升访问者访问的体验。在生产环境中,这是apache调优的一个重要选项之一。
–enable-file-cache //支持文件缓存
–enable-mem-cache //支持记忆缓存
–enable-disk-cache //支持磁盘缓存
–enable-static-support //支持静态连接(默认为动态连接)
–enable-static-htpasswd //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件
–enable-static-htdigest //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件
–enable-static-rotatelogs //使用静态连接编译 rotatelogs - 滚动 apache 日志的管道日志程序
–enable-static-logresolve //使用静态连接编译 logresolve - 解析 apache 日志中的ip地址为主机名
–enable-static-htdbm //使用静态连接编译 htdbm - 操作 dbm 密码数据库
–enable-static-ab //使用静态连接编译 ab - apache http 服务器性能测试工具
–enable-static-checkgid //使用静态连接编译 checkgid
–disable-cgid //禁止用一个外部 cgi 守护进程执行cgi脚本
–disable-cgi //禁止编译 cgi 版本的 php
–disable-userdir //禁止用户从自己的主目录中提供页面
–enable-authn-dbm=shared // 对动态数据库进行操作。rewrite时需要。

还有许多的配置选项,可以通过“./configure –help”来获取配置选项信息。

安装过程中的问题与解决方法

1、如果你的环境中连gcc都没有安装的话,那就先安装gcc。

#yum -y install gcc

2、configure: error: APR not found. Please read the documentation.
系统中未安装APR,可以到apr.apache.org上下载安装。需要安装的有两个,一个是apr,另一个是apr-util。先安装apr,然后安装apr-util,在安装apr-util时需要指定参数--with-apr=PATH,apr默认是安装在/usr/local/apr目录,所以参数可写为--with-apr=/usr/local/apr/

3、configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
需要安装pcre,到www.pcre.org/上下载安装。当然yum也可以直接安装:

yum install -y pcre pcre-devel

安装pcre时可能遇到另一个问题:configure: error: You need a C++ compiler for C++ support.表示没有安装c++支持,安装后继续

#yum -y install gcc-c++

4、checking whether to enable mod_deflate… configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
系统中缺少zlib,安装后继续

#yum -y install zlib-devel

5、checking whether to enable mod_ssl… configure: error: mod_ssl has been requested but can not be built due to prerequisite failures;
系统中缺少openssl,继续安装

yum -y install openssl openssl-devel

6、安装完成后,启动apache时,可能会出现如下提示:

AH00557: httpd: apr_sockaddr_info_get() failed for bogon
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

出现此问题后apache仍然会启动,需要先关掉apache:/usr/local/apache2/bin/apachectl stop,然后修改httpd.conf配置文件,设置ServerName选项,本地测试可设置为ServerName localhost:80,然后重新启动apache即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值