您的位置:首页 > 理论基础 > 计算机网络

centos7源码编译安装httpd、加入systemctl并设置开机自启动

2018-02-01 07:09 741 查看
所需软件:
apr-1.6.3.tar.gz
(下载地址:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz)
apr-util-1.6.1.tar.gz
(下载地址:http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz)
httpd-2.4.29.tar.gz
(下载地址:http://mirrors.shu.edu.cn/apache//httpd/httpd-2.4.29.tar.gz)


安装编译环境:
yum  -y  install  gcc  pcre  pcre-devel  libtool


安装apr:
tar  -xzf  apr-1.6.3.tar.gz
cd  apr-1.6.3/
./configure  &&  make  &&  make  install


安装apr-util:
tar  -xzf  apr-util-1.6.1.tar.gz
cd  apr-util-1.6.1/
./configure  --with-apr=/usr/local/apr/
make  &&  make  install


安装httpd:
tar  httpd-2.4.29.tar.gz
cd httpd-2.4.29/
./configure  &&  make  &&  make  install


编写启动脚本:vim myhttpd
#!/bin/bash
# chkconfig: 12345 80 90
function start_http()
{
/usr/local/apache2/bin/apachectl  start
}
function stop_http()
{
/usr/local/apache2/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  myhttpd
cp  -arf  myhttpd  /etc/init.d/


启动自己编写的服务:
systemctl  start  myhttpd


设置开机自启动:
chkconfig  --add  myhttpd
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  编写 自启动 脚本