yum -y install httpd
[root@promote httpd]# which rotatelogs
/usr/sbin/rotatelogs ## 檢視 rotatelogs命令所在的絕對路徑
[root@promote httpd]# vim /etc/httpd/conf/httpd.conf
ServerName www.kgc.com:80
Listen 192.168.233.100:80
ErrorLog "| /usr/sbin/rotatelogs -l logs/error_%Y%m%d.log 86400 " ## 86400秒爲一天 以一天爲分割
CustomLog "| /usr/sbin/rotatelogs -l logs/access_%Y%m%d.log 86400" combined ## 後面的combined一定要加
[root@promote httpd]# systemctl restart httpd ## 開啓httpd服務
[root@promote httpd]# iptables -F ## 清空防火牆
[root@promote httpd]# setenforce 0 ## 關閉核心防護
yum -y install bind
[root@promote httpd]# vim /etc/named.conf ## 修改主組態檔
listen-on port 53 { any; };
allow-query { any; };
[root@promote httpd]# vim /etc/named.rfc1912.zones ## 修改區域組態檔
zone "kgc.com" IN {
type master;
file "kgc.zone";
allow-update { none; };
};
[root@promote named]# vim /var/named/kgc.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.233.100
[root@promote named]# systemctl start named ## 啓動服務
dns伺服器
存取網站
[root@promote named]# ls /var/log/httpd/
access_log error_log www.kgc.com-access_20200806.log www.kgc.com-error_20200806.log
[root@promote ~]#cronolog-1.6.2-14.el7.x86_64.rpm
[root@promote ~]#rpm -ivh cronolog-1.6.2-14.el7.x86_64.rpm
[root@promote httpd]# vim /etc/httpd/conf/httpd.conf
ServerName www.kgc.com:80
Listen 192.168.233.100:80
ErrorLog "| /usr/sbin/rotatelogs logs/error_%Y%m%d.log " ##
CustomLog "| /usr/sbin/rotatelogs logs/access_%Y%m%d.log " combined ## 後面的combined一定要加
[root@romote conf]#systemctl restart httpd
[root@romote conf]#cd /var/log/httpd
[root@romote httpd]# ll
-rw-r--r--. 1 root root 2418 8月 5 17:33 www.kgc.com-access_20200805.log
-rw-r--r--. 1 root root 2642 8月 5 17:33 www.kgc.com-error_20200805.log
awstats-7.6.tar.gz
[root@promote ~]# tar zxvf awstats-7.6.tar.gz
[root@promote ~]# mv awstats-7.6 /usr/local/awstats
[root@localhost ~]# cd /usr/local/awstats/tools/
[root@promote tools]# ./awstats_configure.pl
……………………………………
Config file path ('none' to skip web server setup):
> /etc/httpd/conf/httpd.conf ## 組態檔路徑
Your web site, virtual server or profile name:
> www.kgc.com //輸入域名
……………… 其他全是Y 或者回車
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
# Order allow,deny
# Allow from all
Require all granted
</Directory>
[root@localhost ~]# vim /etc/awstats/awstats.www.kgc.com.conf
LogFile="/var/log/httpd/access_log" ## 修改存取日誌檔案位置
DirData="/var/lib/awstats" ##awstats 預設不存在 需要建立
[root@promote awstats]#cd /var/lib
[root@promote lib]# mkdir awstats
存取:http://www.kgc.com/awstats/awstats.pl?config=www.kgc.com
[root@localhost ~]# vim /var/www/html/aws.html
<html>
<head>
<meta http-equiv=refresh content="0;url=http://www.kgc.com/awstats/awstats.pl?config=www.kgc.com">
</head>
<body></body>
</html>
~
##### 下次存取 直接存取www.kgc.com/aws.html
[root@localhost ~]# cd /usr/local/awstats/tools
[root@localhost tools]# ./awstats_updateall.pl now ## 更新存取數據
[root@localhost tools]# crontab -e
*/5 * * * * /usr/local/awstats/tools/awstats_updatell.pl now