shell脚本一键部署httpd服务

shell脚本一键部署httpd服务

根据自己需求将下载好的服务压缩包放到/httpd/files目录下,如果版本与我脚本版本不同只需要把脚本里的版本号改成你需要的版本号就行

此脚本可以重复执行也不会报错

项目目录

[root@localhost ]# cd /httpd
[root@localhost httpd]# tree
.
├── install.sh
└── files
    ├── apr-1.7.0.tar.gz
    ├── apr-util-1.6.1.tar.gz
    ├── httpd-2.4.54.tar.gz

install.sh脚本内容

#!/bin/bash

apache_version=2.4.54
apache_install_dir=/usr/local/apache

if [ $UID -ne 0];then
    ehco"请使用管理员用户执行此脚本"
fi

id apache &> /dev/bull
if [ $? -ne 0];then
    useradd -rMs /sbin/nologiin apache
    exit
fi

yum -y install wget vim make openssl-devel pcre-devel expat-devel libtool gcc gcc-c++

rm -rf /tmp/*
tar xf files/apr-1.7.0.tar.gz -C /tmp
tar xf files/apr-util-1.6.1.tar.gz -C /tmp
tar xf files/httpd-2.4.54.tar.gz -C /tmp

sed  -i '/$RM "$cfgfile"/d' /tmp/apr-1.7.0/configure

cd /tmp/apr-1.7.0
if [ ! -d /usr/local/apr ];then
    ./configure --prefix=/usr/local/apr && \
        make && make install
fi

cd ../apr-util-1.6.1
if [ ! -d /usr/local/apr-util ];then
    ./configure --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr && \
        make && make install
fi

cd ../httpd-$apache_version
if [ ! -d $apache_install_dir ];then
        ./configure --prefix=$apache_install_dir \
        --enable-so \
        --enable-ssl \
        --enable-cgi \
        --enable-rewrite \
        --with-zlib \
        --with-pcre \
        --with-apr=/usr/local/apr \
        --with-apr-util=/usr/local/apr-util/ \
        --enable-modules=most \
        --enable-mpms-shared=all \
        --with-mpm=prefork && \
        make && make install && \
fi

echo "export PATH=$apache_install_dir/bin:\$PATH" > /etc/profile.d/httpd.sh
ln -s $apache_install_dir/include /usr/include/httpd &>/dev/null
grep 'apache' /etc/man_db.conf &>/dev/null
if [ $? -ne 0];then
    sed -i "22a MANDATORY_MANPATH  $apache_install_dir/man"  /etc/man_db.conf
fi

cat > /usr/lib/systemd/system/httpd.service << EOF
[Unit]
Description=web server daemon
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecStop=/usr/local/apache/bin/apachectl  stop
ExecReload=/bin/kill -HUP \$MAINPID

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now httpd.service
ss -antl
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,以下是一键部署Zabbix的shell脚本: ```bash #!/bin/bash # 安装依赖 yum -y install httpd php php-mysql php-gd php-xml mariadb mariadb-server mariadb-devel # 启动MariaDB systemctl start mariadb systemctl enable mariadb # 配置MariaDB mysql -e "CREATE DATABASE zabbix character set utf8 collate utf8_bin;" mysql -e "GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'zabbix';" mysql -e "FLUSH PRIVILEGES;" # 导入Zabbix数据库 cd /tmp wget https://repo.zabbix.com/zabbix/5.0/mysql/zabbix-5.0.11-mysql.sql mysql -uzabbix -pzabbix zabbix < zabbix-5.0.11-mysql.sql # 安装Zabbix服务器和代理 rpm -ivh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent # 配置Zabbix服务器 sed -i 's/# DBPassword=/DBPassword=zabbix/g' /etc/zabbix/zabbix_server.conf systemctl start zabbix-server systemctl enable zabbix-server # 配置Zabbix代理 sed -i 's/Server=127.0.0.1/Server=127.0.0.1,zabbix.example.com/g' /etc/zabbix/zabbix_agentd.conf sed -i 's/ServerActive=127.0.0.1/ServerActive=127.0.0.1,zabbix.example.com/g' /etc/zabbix/zabbix_agentd.conf systemctl start zabbix-agent systemctl enable zabbix-agent # 配置Apache sed -i 's/# php_value date.timezone Europe\/Riga/php_value date.timezone Asia\/Shanghai/g' /etc/httpd/conf.d/zabbix.conf systemctl start httpd systemctl enable httpd ``` 注意,该脚本默认使用MariaDB作为数据库,并导入Zabbix 5.0.11版本的数据库文件。如果需要使用其他数据库或版本,请自行修改相应的部分。另外,脚本中的zabbix.example.com为示例域名,需要替换为实际使用的域名。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

随便投投

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值