安装apache:
pcre-8.42.tar.gz
apr-util-1.5.4.tar.gz
apr-1.6.3.tar.gz
httpd-2.4.29.tar.gz
比较稳定的安装包(网盘提取码在最下方)
首先安装环境
yum -y install gcc gcc-c++ wget
安装具体步骤如下:
tar -zxf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix=/usr/local/apr
mkae && make install
tar -zxf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr
make && make install
tar -zxf pcre-8.42.tar.gz
cd pcre-8.42
./configure --prefix=/usr/local/pcre
make && make install
tar -zxf httpd-2.4.29.tar.gz
cd httpd-2.4.29
./configure --prefix=/usr/local/apache/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
make && make install
/usr/local/apache/bin/apachectl start (启动apache)
/usr/local/apache/bin/apachectl stop (停止apache)
/usr/local/apache/bin/apachectl reload (重启apache)
编写开机启动脚本 vim httpd.sh
#!/bin/bash
function start_http(){
/usr/local/apache/bin/apachectl start
}
function stop_http(){
/usr/local/apache/bin/apachectl stop
}
case “$1” in
start)
start_http
;;
stop)
stop_http
;;
restart)
stop_http
start_http
;;
*)
echo “Usage : start | stop | restart”
;;
esac
加入系统服务:
chmod a+x httpd
cp -arf httpd /etc/init.d/
启动自己编写的服务:
systemctl daemon-reload
systemctl start httpd
设置开机自启动:
chkconfig --add httpd
链接:https://pan.baidu.com/s/1_lHE2QH3GZyIPHeyuYz7Sg
提取码:qhh4