腳本編譯安裝httpd服務(wù)

#!/bin/bash
# **********************************************************
#Author:                
#QQ:                     
#Date:                   2021-12-26 23:29
#Filename:               install_http.sh
#Description:            
# **********************************************************
#設(shè)置變量
version=2.4.37
src_dir=/usr/local/src
install_dir=/apps/httpd
#cpu核心數(shù),后面編譯使用
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 
#添加環(huán)境變量
echo 'PATH=/apps/httpd/bin/:$PATH' > /etc/profile.d/httpd.sh
.   /etc/profile.d/httpd.sh
#添加運行服務(wù)的用戶組和用戶
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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容