ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

脚本一键安装apache

2021-09-13 15:59:11  阅读:164  来源: 互联网

标签:脚本 httpd tar apr 一键 util -- usr apache


使用脚本安装apache

[root@node3 apache]# tree
.
├── apache.sh
└── soft
    ├── apr-1.7.0.tar.gz
    ├── apr-util-1.6.1.tar.gz
    └── httpd-2.4.48.tar.gz

apr包下载链接: https://dlcdn.apache.org/apr/apr-1.7.0.tar.gz.
apr-util包下载链接: https://dlcdn.apache.org/apr/apr-util-1.6.1.tar.gz.
httpd包下载链接: https://dlcdn.apache.org/httpd/httpd-2.4.48.tar.gz.

编写脚本

#!/bin/bash

user=apache
apr_version=1.7.0
apr_util_version=1.6.1
httpd_version=2.4.48
httpd_dir=/usr/local/httpd

id $user &>/dev/null
if [ $? -ne 0 ];then
        useradd -r -M -s /sbin/nologin $user
fi

yum groups mark install "Development Tools" -y
yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make wget

rm -rf /usr/src/{apr* httpd*}
tar xf soft/apr-${apr_version}.tar.gz -C /usr/src
tar xf soft/apr-util-${apr_util_version}.tar.gz -C /usr/src
tar xf soft/httpd-${httpd_version}.tar.gz -C /usr/src

#安装apr包
        echo "下载安装apr包"
cd /usr/src/apr-${apr_version}
sed -i '/$RM "$cfgfile"/d' configure
if [ ! -d  /usr/local/apr ];then
    ./configure --prefix=/usr/local/apr  && make && make install
fi

#安装apr-util包
        echo "下载安装apr-util包"
cd /usr/src/apr-util-${apr_util_version}
if [ ! -d /usr/local/apr-util ];then
    ./configure  --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install
fi

#安装httpd包
        echo "下载安装httpd包"
cd /usr/src/httpd-${httpd_version}
if [ ! -d ${httpd_dir} ];then
    ./configure --prefix=${httpd_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

sed -i 's/#ServerName www.example.com:80/ServerName www.example.com:80/g' /usr/local/httpd/conf/httpd.conf
echo 'export PATH=/usr/local/httpd/bin:$PATH' > /etc/profile.d/httpd.sh

cat > /usr/lib/systemd/system/httpd.service  << EOF
[Unit]
Description=The Apache http server
After=network.targe

[Service]
Type=forking
ExecStart=/usr/local/httpd/bin/apachectl start
ExecStop=/usr/local/httpd/bin/apachectl stop
ExecReload=/usr/local/httpd/bin/apachectl restart

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now httpd

查看端口

[root@node3 apache]# ss -antl
State        Recv-Q       Send-Q              Local Address:Port               Peer Address:Port               
LISTEN       0            128                             *:80                            *:*  

标签:脚本,httpd,tar,apr,一键,util,--,usr,apache
来源: https://blog.csdn.net/NeaWalke/article/details/120267299

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有