第一种方法
一、下载解压
wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.29.tar.gzwget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gzwget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gztar -vxf httpd-2.4.29.tar.gztar -vxf apr-1.6.3.tar.gztar -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/aprmake && make install
2、编译apr-util
cd apr-util-1.6.1./configure --prefix=/app/apr-util --with-apr=/app/aprmake && 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 httpd24chkconfig httpd24 onservice 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
后面的步骤和第一种方法一样
原文地址:https://www.cnblogs.com/reset-li/p/8409840.html
时间: 2024-10-29 19:12:20