新聞中心
源碼安裝apache腳本部署
[root@localhost ~]# ls
anaconda-ks.cfg httpd.tar.xz
[root@localhost ~]# tar xf httpd.tar.xz 解壓存放腳本的壓縮包
[root@localhost ~]# ls
anaconda-ks.cfg httpd httpd.tar.xz
[root@localhost ~]# cd httpd/
[root@localhost httpd]# ls
apache_lnh.sh(編譯安裝apache腳本) config.sh(附屬腳本) files
[root@localhost httpd]# ls files/ //存放安裝包的目錄
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.53.tar.gz httpd-2.4.54.tar.gz zhuawawa(源碼包的目錄)
[root@localhost httpd]# cat apache_lnh.sh
#/bin/bash

“只有客戶發(fā)展了,才有我們的生存與發(fā)展!”這是創(chuàng)新互聯(lián)公司的服務(wù)宗旨!把網(wǎng)站當作互聯(lián)網(wǎng)產(chǎn)品,產(chǎn)品思維更注重全局思維、需求分析和迭代思維,在網(wǎng)站建設(shè)中就是為了建設(shè)一個不僅審美在線,而且實用性極高的網(wǎng)站。創(chuàng)新互聯(lián)對網(wǎng)站設(shè)計制作、成都網(wǎng)站設(shè)計、網(wǎng)站制作、網(wǎng)站開發(fā)、網(wǎng)頁設(shè)計、網(wǎng)站優(yōu)化、網(wǎng)絡(luò)推廣、探索永無止境。
#列出httpd版本號進行選擇
cat > /tmp/xbz.txt <
1. 2.4.54
2. 2.4.53
q. 退出
EOF
cat /tmp/xbz.txt
read -p “選擇版本號” apache_version
case $apache_version in
1)
apache_version=$(awk ‘NR==2{print $2}’ /tmp/xbz.txt)
echo $apache_version
;;
2)
apache_version=$(awk ‘NR==3{print $2}’ /tmp/xbz.txt)
echo $apache_version
;;
q)
apache_version=$(awk ‘NR==4{print $2}’ /tmp/xbz.txt)
echo $apache_version
exit
;;
*)
echo “錯誤輸入”
exit
esac
#設(shè)置執(zhí)行權(quán)限
if [ $UID -ne 0 ];then
echo “請以管理員用戶進行執(zhí)行”
exit
fi
#定義變量
install_dir=/usr/local/apache
#創(chuàng)建用戶
id apache &> /dev/null
if [ $? -ne 0 ];then
useradd -r -M -s /sbin/nologin apache
else
echo “用戶已存在”
fi
#安裝依賴包
dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ wget make vim zip –allowerasing
#解壓源碼包
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-$apache_version.tar.gz -C /tmp/
#編譯安裝apr
cd /tmp/apr-1.7.0
if [ ! -d /usr/local/apr ];then
sed -i ‘/$RM “$cfgfile”/d’ configure
./configure –prefix=/usr/local/apr && \
make && make install
else
ls /usr/local
echo “apr 編譯安裝完成”
fi
#編譯安裝apr-util
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
else
ls /usr/local/
echo “apr-util 編譯安裝完成”
fi
#編譯安裝httpd
cd ../httpd-$apache_version/
if [ ! -d ${install_dir} ];then
./configure –prefix=${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
else
ls ${install_dir}
echo “httpd 編譯安裝完成”
fi
#設(shè)置環(huán)境變量,man文檔,頭文件
echo “export PATH=${install_dir}/bin:\$PATH” > /etc/profile.d/apache.sh
ln -s ${install_dir}/include /usr/include/apache &> /dev/null
grep ‘a(chǎn)pache’ /etc/man_db.conf &> /dev/null
if [ $? -ne 0 ];then
sed -i “22a MANDATORY_MANPATH ${install_dir}/man” /etc/man_db.conf
fi
#將其加入systemd服務(wù)里面
cat > /usr/lib/systemd/system/httpd.service <
Description=httpd server daemon
After=network.target
[Service]
Type=forking
ExecStart=${install_dir}/bin/apachectl start
ExecStop=${install_dir}/bin/apachectl stop
ExecReload=/bin/kill -HUP \$MAINPID
[Install]
WantedBy=multi-user.target
EOF
#加載文件并設(shè)置開機自啟
systemctl daemon-reload
systemctl enable –now httpd
#查看端口
ss -antl
[root@localhost httpd]# cat config.sh
#!/bin/bash
#定義變量
install_dir=$(grep ‘^install_dir=’ apache_lnh.sh | awk -F’=’ ‘{print $2}’ )
echo $install_dir
#添加包含虛擬主機
grep ‘Include conf/extra/httpd-vhosts.conf’ $install_dir/conf/httpd.conf &> /dev/null
if [ $? -eq 0 ];then
echo “Include conf/extra/httpd-vhosts.conf” >> $install_dir/conf/httpd.conf
fi
#配置虛擬主機
cat > $install_dir/conf/extra/httpd-vhosts.conf <
DocumentRoot “$install_dir/htdocs/zhuawawa.example.com”
ServerName zhuawawa.example.com
ErrorLog “l(fā)ogs/zhuawawa.example.com-error_log”
CustomLog “l(fā)ogs/zhuawawa.example.com-access_log” common
EOF
#添加防火墻規(guī)則
firewall-cmd –add-rich-rule ‘rule family=ipv4 source address=0.0.0.0/0 port port=80 protocol=tcp accept’ –permanent &> /dev/null
firewall-cmd –reload
#創(chuàng)建網(wǎng)站存放目錄
mkdir -p $install_dir/htdocs/zhuawawa.example.com
cp -r files/zhuawawa/* $install_dir/htdocs/zhuawawa.example.com
#重啟httpd
systemctl restart httpd
#查看端口
ss -antl
[root@localhost httpd]# ls
apache_lnh.sh config.sh files
[root@localhost httpd]# ls files/
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.53.tar.gz httpd-2.4.54.tar.gz zhuawawa(提前將源碼包解壓到這里)
[root@localhost httpd]# ls files/zhuawawa/ (此處是我解壓的源碼包)
Battle_City audio css images index.html js tk.zip
進行訪問:
[root@localhost ~]# tar -Jcf httpd.tar.xz httpd/ //壓縮腳本存放目錄
[root@localhost ~]# ls
anaconda-ks.cfg httpd httpd.tar.xz
到此這篇關(guān)于源碼安裝apache腳本部署的文章就介紹到這了,更多相關(guān)源碼安裝apache內(nèi)容請搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!
Linux 技術(shù)文檔 操作系統(tǒng)
數(shù)據(jù)庫運維技術(shù)服務(wù) ? 源碼安裝apache腳本部署過程詳解
LinuxSA 普通
分享到:
四川成都云服務(wù)器租用托管【創(chuàng)新互聯(lián)】提供各地服務(wù)器租用,電信服務(wù)器托管、移動服務(wù)器托管、聯(lián)通服務(wù)器托管,云服務(wù)器虛擬主機租用。成都機房托管咨詢:13518219792
創(chuàng)新互聯(lián)(www.cdcxhl.com)擁有10多年的服務(wù)器租用、服務(wù)器托管、云服務(wù)器、虛擬主機、網(wǎng)站系統(tǒng)開發(fā)經(jīng)驗、開啟建站+互聯(lián)網(wǎng)銷售服務(wù),與企業(yè)客戶共同成長,共創(chuàng)價值。
本文題目:源碼安裝apache腳本部署過程詳解
當前網(wǎng)址:http://m.fisionsoft.com.cn/article/dpgijcd.html


咨詢
建站咨詢
