wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.33.tar.gz
apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可很方便地移植(从linux移植到windows) 它是靠函数来运行,无论系统平台是什么都不会影响。
分别解压apr-1.6.3 apr-util 1.6.1 httpd-2.4.33
tar zxvf httpd-2.4.33.tar.gz
tar jxvf apr-util-1.6.1.tar.bz2
ar zxvf apr-1.6.3.tar.gz
首先安装apr
cd /usr/local/src/apr-1.6.3.tar.gz
./configure --prefix=/usr/local/apr
检查是否成功
echo $?
0
make && make install 检查是否成功
echo $?
0
然后安装apr-util 1.6.1
cd /usr/local/src/apr-util-1.6.1 apr-util要依赖apr的路径
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
发现错误
解决方法:
缺少expat.h文件,yum安装:#yum install -y expat-devel;安装完成后,重新执行上面的命令!
安装httpd-2.4
#cd /usr/local/src/httpd-2.4.33 安装参数
./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/lcal/apr-util --enable-so --enable-mods-shared=most ./configure \ //这里的反斜杠是脱义字符,加上它我们可以把一行命令写成多行
--prefix=/usr/local/apache2.4 \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--enable-so \ 支持动态扩展模块,apache php都支持以一个模块存在。
--enable-mods-shared=most 支持大部分模块
安装期间,出现报错信息,大致内容就是缺了某个包。
利用#yum list 去追踪导致错误信息的包
yum list
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
再次编译,继续出错,继续排查安装包
./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/lcal/apr-util --enable-so --enable-mods-shared=most
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for APR-util... configure: error: the --with-apr-util parameter is incorrect. It must specify an install prefix, a build directory, or an apu-config file. 解决方法:
# 安装libxml2-devel包
yum install -y libxml2-devel
make && make install
利用一般devel就是库包,所以选择安装有关devel的包名安装。
[root@Centos7-01 httpd-2.4.33]# yum list |grep -i pcre
pcre-devel.x86_64 8.32-17.el7 base
再次./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
make && make install
ls /usr/local/apache2.4/modules
/usr/local/apache2.4/bin/httpd -M //查看加载的模块
[root@DD-Server-9F ~]# /usr/local/apache2.4/bin/httpd -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::2ad9:5a78:700c:eaee. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_event_module (static)
authn_file_module (shared)
authn_core_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_core_module (shared)
access_compat_module (shared)
auth_basic_module (shared)
reqtimeout_module (shared)
filter_module (shared)
mime_module (shared)
log_config_module (shared)
env_module (shared)
headers_module (shared)
setenvif_module (shared)
version_module (shared)
unixd_module (shared)
status_module (shared)
autoindex_module (shared)
dir_module (shared)
alias_module (shared)
httpd简化版安装
####3 安装apache
分别下载 apr-1.6.3 apr-util 1.6.1 httpd-2.4.33 到/usr/local/src/
wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.33.tar.gz
首先安装apr
cd /usr/local/src/apr-1.6.3
./configure --prefix=/usr/local/apr
然后安装apr-util 1.6.1
cd /usr/local/src/apr-util-1.6.1
apr-util要依赖apr的路径
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
安装httpd-2.4
#cd /usr/local/src/httpd-2.4.33
#./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-
util=/usr/local/apr-util --enable-so --enable-mods-shared=most
#make && make install