其他分享
首页 > 其他分享> > cento8.3初始化脚本&编译安装httpd脚本

cento8.3初始化脚本&编译安装httpd脚本

作者:互联网

cento8.3初始化脚本

#!/bin/bash
###init_centos8.3###

#关闭防火墙
systemctl disable --now firewalld
sed -i.bak -r 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
echo $? && echo ===================firewalld==========================================


mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
cat > /etc/yum.repos.d/base.repo <<EOF
[BaseOS]
name=BaseoOS
baseurl=https://mirrors.aliyun.com/centos-vault/8.3.2011/BaseOS/x86_64/os/
        https://mirrors.cloud.tencent.com/centos-vault/8.3.2011/BaseOS/x86_64/os/
gpgcheck=0

[APPStream]
name=APPStrream
baseurl=https://mirrors.cloud.tencent.com/centos-vault/8.3.2011/AppStream/x86_64/os/
        https://mirrors.aliyun.com/centos-vault/8.3.2011/AppStream/x86_64/os/
gpgcheck=0

[epel]
name=epel
baseurl=https://mirrors.aliyun.com/epel/8/Everything/x86_64/
        https://mirrors.cloud.tencent.com/epel/8/Everything/x86_64/
gpgcheck=0

EOF
yum makecache
echo $? && echo ===================yum==========================================

#常用软件安装
yum install install lrzsz tree screen tmux man-pages strace redhat-lsb-core bash-completion chrony net-tools
echo $? && echo ===================soft==========================================


#时间同步配置
timedatectl set-timezone Asia/Shanghai
echo $? && echo ===============time==============================================

#修改history样式
echo "HISTTIMEFORMAT='%F %T    '" >> /root/.bash_profile
source /root/.bash_profile
echo $? && echo ===============history==============================================


#修改网卡名称
sed -r -i.bak '/^GRUB_CMDLINE_LINUX=/s/"$/ net.ifnames=0"/' /etc/default/grub  
grub2-mkconfig -o /boot/grub2/grub.cfg

echo $? && echo ================eth0=============================================

  

编译安装httpd

#!/bin/bash
###make install httpd###
yum -y install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config bzip2 wget

echo $? && echo ============depends package===================
wget -P /user/local/src https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.bz2

cd /user/local/src

tar -jxf httpd-2.4.52.tar.bz2

cd /user/local/src/httpd-2.4.52

echo $? && echo =========download======================

./configure --prefix=/apps/httpd/ --sysconfdir=/etc/httpd/ --enable-ssl

make -j 2

make install
echo $? && echo ==========install=====================

echo 'PATH=$PATH:/apps/httpd/bin/' > /etc/profile.d/httpd.sh
source /etc/profile.d/httpd.sh
bash /etc/profile.d/httpd.sh
echo $? && echo ============bin===================

groupadd -r -g 48 apache
useradd -r -u 48 -g 48 -d /var/www/ -c "apache" -s /sbin/nologin apache
echo $? && echo ===========useradd====================

sed -i.bak -r -e 's/^User daemon/User apache/' -e 's/^Group daemon/Group apache/' /etc/httpd/httpd.conf
echo $? && echo ============config===================

apachectl start
echo $? && echo =============start==================

  初级版本,很粗糙

标签:脚本,httpd,cento8.3,echo,etc,&&,apache,bak
来源: https://www.cnblogs.com/big227/p/15973097.html