CentOS7 编译安装Apache Httpd2.4
注意:文中使用root用户,其他用户请注意权限分配
1、安装依赖,系统为最小化安装,很多东西都有没有,使用root用户执行:
yum -y install gcc libtool expat-devel gcc-c++ pcre-devel
关闭防火墙、selinux
2、下载依赖插件源码、httpd源码、解压并创建安装目录:
wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.5.tar.bz2
wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
# wget -c http://ftp.pcre.org/pub/pcre/pcre-8.45.tar.bz2 已经没了,用这个,复制到浏览器下载:
https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz/download
wget -c http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.52.tar.bz2
tar -jxvf apr-1.6.5.tar.bz2
tar -jxvf apr-util-1.6.1.tar.bz2
tar -jxvf pcre-8.45.tar.bz2
tar -jxvf httpd-2.4.52.tar.bz2
mkdir /usr/local/apr
mkdir /usr/local/apr-util
mkdir /usr/local/pcre
mkdir /usr/local/httpd
3、编译安装:
# 安装apr
cd
cd apr-1.6.5
./configure --prefix=/usr/local/apr/
# 配置报错:cannot remove `libtoolT’: No such file or directory ,编辑 configure文件,查找 $RM "$cfgfile" 这个地方,删除该行,或者#注释掉
make && make install
# 安装apr-util
cd
cd apr-util-1.6.3
./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/
make && make install
# 安装pcre
cd
cd pcre-8.45
./configure --prefix=/usr/local/pcre/
make && make install
# 安装httpd
cd
# 拷贝编译好的apr、apr-util 到apache的 srclib 目录,防止安装失败:
cp -r apr-1.6.5 httpd-2.4.52/srclib/apr
cp -r apr-util-1.6.3 httpd-2.4.52/srclib/apr-util
cd httpd-2.4.52
./configure --with-included-apr --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most --enable-module=so
make && make install
4、测试是否安装成功:
cd /usr/local/httpd/conf
vi httpd.conf
# 修改 ServerName www.examda.com:80 为:
localhost:8099
# 启动服务:
./../bin/apachectl start
# 打开浏览器,访问:xxxxxxx:8099,显示:
It works!
安装完成!