真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Shell腳本一鍵進行Apache服務(wù)的優(yōu)化

使用Shell腳本一鍵進行Apache服務(wù)的優(yōu)化

(包含日志分割、日志文件分析系統(tǒng)、靜態(tài)資源壓縮、設(shè)置網(wǎng)頁緩存時間、防盜鏈、系統(tǒng)版本號隱藏)

本次實驗使用軟件包合集(均為開源軟件):鏈接:https://pan.baidu.com/s/1Byuu3PWgCap85lqfqrA6eA 提取碼:x806 請?zhí)砑渔溄用枋?/p>

創(chuàng)新互聯(lián)建站擁有網(wǎng)站維護技術(shù)和項目管理團隊,建立的售前、實施和售后服務(wù)體系,為客戶提供定制化的成都網(wǎng)站設(shè)計、網(wǎng)站制作、網(wǎng)站維護、IDC機房托管解決方案。為客戶網(wǎng)站安全和日常運維提供整體管家式外包優(yōu)質(zhì)服務(wù)。我們的網(wǎng)站維護服務(wù)覆蓋集團企業(yè)、上市公司、外企網(wǎng)站、成都商城網(wǎng)站開發(fā)、政府網(wǎng)站等各類型客戶群體,為全球近千家企業(yè)提供全方位網(wǎng)站維護、服務(wù)器維護解決方案。

安裝步驟:手工編譯安裝apache→安裝DNS服務(wù)→進行日志分割→安裝日志文件分析系統(tǒng)→對靜態(tài)資源進行壓縮→設(shè)施網(wǎng)頁緩存時間→防盜鏈設(shè)置→版本號隱藏

#!/bin/bash

yum install bind expect -y
#安裝基礎(chǔ)DNS及expect免交互

read -p "提供硬盤的IP:" ip
smbclient -L //$ip/ <<-eof

eof
read -p "請輸入想掛載的文件夾:" test
mount.cifs -o username="******",password="******" //$ip/$test /mnt
#賬戶密碼請自定義

df -hT | grep -o "cifs" &> /dev/null
if [ $? -eq 0 ];then
  echo "掛載成功,開始安裝"
else
  echo "失敗,請重來"
  exit 1
fi
#遠程掛載

yum -y install \
gcc \
gcc-c++ \
pcre \
pcre-devel \
zlib-devel \
expat-devel
#安裝環(huán)境包

cd /mnt
tar xjf httpd-2.4.29.tar.bz2 -C /opt
tar zxf apr-1.6.2.tar.gz -C /opt/
tar zxf apr-util-1.6.0.tar.gz -C /opt/
rpm -ivh cronolog-1.6.2-14.el7.x86_64.rpm

cd /opt
mv apr-1.6.2/ httpd-2.4.29/srclib/apr
mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util

cd httpd-2.4.29/
./configure \
--prefix=/usr/local/httpd \
--enable-so \
--enable-deflate \
--enable-expires \
--enable-rewrite \
--enable-charest-lite \
--enable-cgi 
make && make install
#編譯安裝

quanju="/etc/named.conf"
quyu="/etc/named.rfc1912.zones"
zhu=`ifconfig ens33 | awk 'NR==2{print $2}'`

sed -i -e "13s/127.0.0.1/any/" -e '21s/localhost/any/' $quanju
sed -i "18azone \"zhy.com\" IN {\n  type master\;\n  file \"zhy.zone\"\;\n}\;\n" $quyu
cp -p /var/named/named.localhost /var/named/zhy.zone
sed -i -e '$d' /var/named/zhy.zone
echo "www  IN A    $zhu" >> /var/named/zhy.zone
#DNS配置

http="/usr/local/httpd/conf/httpd.conf"
sed -i -e '/Listen 80/s/^/#/' -e "/#Listen 12.34.56.78:80/s/#Listen 12.34.56.78:80/Listen $zhu:80/" $http
sed -i '/#ServerName www.example.com/s/#ServerName www.example.com/ServerName www.zhy.com/' $http
cd /usr/local/httpd/bin/
./apachectl start
sed -i '/ErrorLog \"logs\/error_log\"/s/ErrorLog \"logs\/error_log\"/ErrorLog \"\| \/usr\/sbin\/cronolog logs\/www.zhy.com.error_\%Y\%m\%d.log\"/' $http
sed -i '/CustomLog \"logs\/access_log\" common/s/CustomLog \"logs\/access_log\" common/CustomLog \"\| \/usr\/sbin\/cronolog logs\/www.zhy.com.access_\%Y\%m\%d.log\" combined/' $http
#HTTP服務(wù)改監(jiān)聽、改域名

ln -s /usr/local/httpd/bin/* /etc/init.d/ 
service apachectl stop
service apachectl start
#日志分割

cd /mnt
tar zxf awstats-7.6.tar.gz
mv awstats-7.6 /usr/local/awstats
cd /usr/local/awstats/tools/
expect <<-eof
    spawn ./awstats_configure.pl

    expect ">" {send "/usr/local/httpd/conf/httpd.conf\r"}
    expect "y/N" {send "y\r"}
    expect ">" {send "www.zhy.com\r"}
    expect ">" {send "\r"}
    expect "continue..." {send "\r"}
    expect "finish..." {send "\r"}
eof
time=`date -d 'today' '+%Y%m%d'`
ls /usr/local/httpd/logs/ | grep "$time"
if [ $? -eq 0 ];then
  sed -i "50s/\/var\/log\/httpd\/mylog.log/\/usr\/local\/httpd\/logs\/www.zhy.com.access_$time.log/" /etc/awstats/awstats.www.zhy.com.conf
fi

sed -i "/LogFormat=1/s/1/4/" /etc/awstats/awstats.www.zhy.com.conf
mkdir /var/lib/awstats
sed -i "/#LoadModule cgid_module modules\/mod_cgid.so/aLoadModule cgid_module modules\/mod_cgid.so" $http
sed -i -e '/Order allow,deny/s/^/#/' -e '/Allow from all/s/^/#/' $http
sed -i '/Allow from all/a    Require all granted' $http
echo "* * 1 * * ls /usr/local/httpd/logs/ | grep $time &> /dev/null && sed -i \"50s/\/var\/log\/httpd\/mylog.log/\/usr\/local\/httpd\/logs\/www.zhy.com.access_$time.log/\" root /etc/awstats/awstats.www.zhy.com.conf" >> /etc/crontab

echo "*/5 * * * * root /usr/local/awstats/tools/awstats_updateall.pl now" >> /etc/crontab
/bin/systemctl reload crond.service
systemctl enable crond
#創(chuàng)建計劃性任務(wù)

touch /usr/local/httpd/htdocs/houtai.html
echo "" >> /usr/local/httpd/htdocs/houtai.html
echo "  " >> /usr/local/httpd/htdocs/houtai.html
echo "   " >> /usr/local/httpd/htdocs/houtai.html
echo "  " >> /usr/local/httpd/htdocs/houtai.html
echo "  " >> /usr/local/httpd/htdocs/houtai.html
echo "" >> /usr/local/httpd/htdocs/houtai.html
service apachectl stop
service apachectl start
systemctl stop firewalld.service 
setenforce 0
systemctl start named
#日志文件分割系統(tǒng)

cd /mnt
sed -i '/LoadModule deflate_ module modules\/mod_ deflate.so/s/#/ /' $http
echo "" >> $http
echo "    AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript" >> $http
echo "    DeflateCompressionLevel 9" >> $http
echo "    SetOutputFilter DEFLATE" >> $http
echo "" >> $http
#靜態(tài)資源壓縮

sed -i '/LoadModule expires_module/s/#/ /' $http
echo "" >> $http
echo "    ExpiresActive On" >> $http
echo "    ExpiresDefault \"access plus 30 seconds\"" >> $http
echo "" >> $http
#網(wǎng)頁緩存時間

sed -i '/LoadModule rewrite_module/s/#/ /' $http
sed -i '248a    RewriteEngine On\n    RewriteCond %{HTTP_REFERER} !^http://zhy.com/.*$ [NC]\n    RewriteCond %{HTTP_REFERER} !^http://zhy.com$ [NC]\n    RewriteCond %{HTTP_REFERER} !^http://www.zhy.com/.*$ [NC]\n    RewriteCond %{HTTP_REFERER} !^http://www.zhy.com/$ [NC]\n    RewriteRule .*\\.(gif|jpg|swf)$ /upload/otherpic48/16809.jpg' $http
#防盜鏈,防盜圖片請放到默認站點htdocs中

sed -i '/httpd-default.conf/s/#/ /' $http
default="/usr/local/httpd/conf/extra/httpd-default.conf"
sed -i '55s/Full/Prod/' $default
#隱藏版本號

service apachectl stop
service apachectl start
echo "本機IP為:$zhu"

網(wǎng)頁題目:Shell腳本一鍵進行Apache服務(wù)的優(yōu)化
本文地址:http://weahome.cn/article/gjohsc.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部