1、安装编译环境
yum -y install wget make gcc gcc-c++ pcre openssl openssl-devel zlib unzip cmake ncurses-devel libjpeg libjpeg-devel libpng libpng-devel libxml2 libxml2-devel curl-devel libtool libtool-ltdl libtool-ltdl-devel libevent libevent-devel zlib-static zlib-devel autoconf pcre-devel gd perl freetype freetype-devel expat-devel
2、安装apr
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.5.tar.gz
tar xf apr-1.6.3.tar.gz
cd apr-1.6.3
vim configure
找到RM='$M' 修改为RM=‘$RM -f’
./configure --prefix=/usr/local/apr/
make
make install
3、安装 apr-util
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
4、编译安装apache
#创建运行apache的用户
groupadd www
useradd -g www www -s /bin/false
#下载软件
wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.29.tar.gz
tar -zxvf httpd-2.4.29.tar.gz
cd httpd-2.4.29
#编译
./configure --prefix=/usr/local/httpd/
–sysconfdir=/etc/httpd/
–with-include-apr
–disable-userdir
–enable-headers
–with-mpm=worker
–enable-modules=most
–enable-so
–enable-deflate
–enable-defate=shared
–enable-expires-shared
–enable-rewrite=shared
–enable-static-support
–with-apr=/usr/local/apr/
–with-apr-util=/usr/local/apr-util/bin
–with-ssl
–with-z
make
make install
哎呀我天这就过不去了、、、、、
报错解决办法
https://blog.51cto.com/castiel/2051440
yum install gcc gcc-c++ prce-devel expat-devel
yum install -y libxml2-devel
[root@localhost ~]# rm -rf /usr/local/apr-util
[root@localhost ~]# cd /usr/local/src/apr-util-1.6.1
必须清除之前配置时的缓存
[root@localhost apr-util-1.6.1]# make clean
源码安装三步走
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.6.1]# make
[root@localhost apr-util-1.6.1]# make install
继续编译apache
./configure --prefix=/usr/local/httpd/
–sysconfdir=/etc/httpd/
–with-include-apr
–disable-userdir
–enable-headers
–with-mpm=worker
–enable-modules=most
–enable-so
–enable-deflate
–enable-defate=shared
–enable-expires-shared
–enable-rewrite=shared
–enable-static-support
–with-apr=/usr/local/apr/
–with-apr-util=/usr/local/apr-util/bin
–with-ssl
–with-z
呵呵、、过去了。。。。
make && make install
修改apache配置(/etc/httpd/httpd.conf)
vim /etc/httpd/httpd.conf
增加apache环境变量
cat >> /etc/profile << END
export PATH=$PATH:/usr/local/httpd/bin/
END
source /etc/profile
设置启动项服务
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
修改你的vim /etc/init.d/httpd脚本 在开始处#!/bin/bash之后的行后插入
增加服务
chkconfig --add httpd
chkconfig --level 2345 httpd on
启动|停止|重启apache方式
启动|停止|重启 /etc/init.d/httpd start|stop|restart
#扩展
启动 /usr/local/httpd/bin/apachectl -f /etc/httpd/httpd.conf
暴力停止 /usr/local/httpd/bin/apachectl -k stop
优雅停止 /usr/local/httpd/bin/apachectl -k graceful-stop
优雅的重启 /usr/local/httpd/bin/apachectl -k graceful
暴力重启 /usr/local/httpd/bin/apachectl -k restart
启动报错
需要修改httpd.com里面的servername字段
servername localhost:80
然后重启即可
/etc/init.d/httpd restart