脚本编译安装httpd服务

#!/bin/bash
# **********************************************************
#Author:                
#QQ:                     
#Date:                   2021-12-26 23:29
#Filename:               install_http.sh
#Description:            
# **********************************************************
#设置变量
version=2.4.37
src_dir=/usr/local/src
install_dir=/apps/httpd
#cpu核心数,后面编译使用
cpu=`lscpu | sed -rn '/^CPU\(s\)/s/.* ([0-9]+)/\1/p'`
wget -P /usr/local/src https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-$version.tar.bz2 &> /dev/null || { echo download faild ; exit; }

cd $src_dir
tar xvf httpd-$version.tar.bz2
#安装编译、安装需要的包
yum -y  install  gcc apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config-123-1.el8.noarch
cd httpd-$version/
#配置
./configure --prefix=$install_dir --sysconfdir=/etc/httpd --enable-ssl
#编译成功后安装
make -j $cpu && make install 
#添加环境变量
echo 'PATH=/apps/httpd/bin/:$PATH' > /etc/profile.d/httpd.sh
.   /etc/profile.d/httpd.sh
#添加运行服务的用户组和用户
groupadd -r -g 88 apache
useradd -r -u 88 -g apache -s /sbin/nologin -d $install_dir apache
sed -i  -e '/^User/c User apache' -e '/^Group/c Group apache'  /etc/httpd/httpd.conf

apachectl -k start
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容