第一种方法
一、下载解压
wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.29.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
tar -vxf httpd-2.4.29.tar.gz
tar -vxf apr-1.6.3.tar.gz
tar -vxf apr-util-1.6.1.tar.gz
二、安装开发包组和相关依赖包
yum groupinstall "Development tools" yum install openssl-devel pcre-devel expat-devel
三、编译apr和apr-util
httpd是依赖于apr的,所以先编译apr和apr-util
1、编译apr
cd apr-1.6.3 ./configure --prefix=/app/apr
make && make install
2、编译apr-util
cd apr-util-1.6.1
./configure --prefix=/app/apr-util --with-apr=/app/apr
make && make install
四、编译httpd
cd httpd-2.4.29 ./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/app/apr/ --with-apr-util=/app/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make && make install
五、环境变量
echo ‘PATH=/app/httpd24/bin/:$PATH‘ > /etc/profile.d/httpd24.sh . /etc/profile.d/httpd24.sh
六、创建用户和组
useradd -r -s /sbin/nologin apache
七、修改配置文件
vim /app/httpd24/conf/httpd.conf
修改
User apache
Group apache
八、启动脚本
vim /etc/init.d/httpd24 apachectl=/app/httpd24/bin/apachectl httpd=${HTTPD-/app/httpd24/bin/httpd} pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid} lockfile=${LOCKFILE-/var/lock/subsys/httpd24}
chkconfig --add httpd24
chkconfig httpd24 on
service httpd24 start
第二种方法
一、下载解压
wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.29.tar.gz wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz tar -vxf httpd-2.4.29.tar.gz tar -vxf apr-1.6.3.tar.gz tar -vxf apr-util-1.6.1.tar.gz
二、安装开发包组和相关依赖包
yum groupinstall "Development tools" yum install openssl-devel pcre-devel expat-devel
三、拷贝apr和apr-util源码包
cp -r apr-1.6.3 httpd-2.4.29/srclib/apr cp -r apr-util-1.6.1 httpd-2.4.29/srclib/apr-util
三、编译
cd httpd-2.4.29 ./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
make && make install
后面的步骤和第一种方法一样