LOADING STUFF...

RHEL5搭建apache服务器全过程(五)部署awstats、phpMyAdmin以及备份MySQL

–>

 1、在web1和web2上分别部署awstats

首先需要建立虚拟主机,DNS将www.eyo.com指向192.168.0.225
web1和web2上的此虚拟主机应该是一模一样的:
<VirtualHost 192.168.0.225>
    DocumentRoot “/usr/local/apache2/htdocs/eyo”
    ServerName www.eyo.com
    ErrorLog “logs/www.eyo.com.error.log”
    CustomLog “logs/www.eyo.com.access.log” common
</VirtualHost>
 
web1和web2都需给根目录添加一个虚拟主机
<VirtualHost 192.168.0.225>
    DocumentRoot /usr/local/apache2/htdocs
    ServerName web1.eyo.com
</VirtualHost>
 
重启服务:

[[email protected] ~]# /usr/local/apache2/bin/apachectl restart
 
 
部署awstats的主要步骤如下:

[[email protected] Desktop]# tar zxvf awstats-6.9.tar.gz -C /usr/local/
[[email protected] Desktop]# mv /usr/local/awstats-6.9/ /usr/local/awstats
[[email protected] Desktop]# cd /usr/local/awstats/tools/
[[email protected] tools]# ./awstats_configure.pl 

 
此时会进入一个交互式模式,这里不再赘述,只进行简单的操作,先按提示输入两次”y“,然后输入你的站点名称,我这里输入www.eyo.com,后面都可以直接回车即可
 
[[email protected] tools]# vim /etc/awstats/awstats.www.eyo.com.conf

          51   LogFile=”/usr/local/apache2/logs/www.eyo.com.access.com”
 
[[email protected] tools]# mkdir /var/lib/awstats
[[email protected] tools]# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.eyo.com

这里需要格外注意:执行第一次时,可能不会报错,因为日志里面根本不存在任何信息,所以你可以试着在本机*问http://www.eyo.com进行测试,确定生成了日志之后,再执行上一条命令,很可能会报错:
 
AWStats did not find any valid log lines that match your LogFormat parameter, in the 50th first non commented lines read of your log.
Your log file /usr/local/apache2/logs/www.eyo.com.access.com must have a bad format or LogFormat parameter setup does not match this format.
 
并且重启apache服务,也会报错:

[[email protected] tools]# /usr/local/apache2/bin/apachectl restart
httpd: Syntax error on line 414 of /usr/local/apache2/conf/httpd.conf: /usr/local/apache2/conf/httpd.conf:414: <VirtualHost> was not closed.
 
解决办法:
先根据提示,修改/usr/local/apache2/conf/httpd.conf文件,会发现大约418行最后的日志格式变成了combined,虚拟主机的结束语句</VirtualHost>自动跳到了这一行,只需把其移动到下一行即可,然后进行以下操作:
 

[[email protected] tools]# cd /usr/local/apache2/logs/
[[email protected] logs]# rm -fr www.eyo.com.*
[[email protected] logs]# /usr/local/apache2/bin/apachectl restart
 
然后在本机上再次进行测试访问http://www.eyo.com,再执行:
[[email protected] logs]# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.eyo.com
 
会回显如下结果:
Create/Update database for config “/etc/awstats/awstats.www.eyo.com.conf” by AWStats version 6.9 (build 1.925)
From data in log file “/usr/local/apache2/logs/www.eyo.com.access.com”…
Phase 1 : First bypass old records, searching new record…
Searching new records from beginning of log file…
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)…
Jumped lines in file: 0
Parsed lines in file: 154
 Found 0 dropped records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 154 new qualified records.
 

做计划任务

[[email protected] ~]# crontab -e
 
* */5 * * * perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.eyo.com

[[email protected] ~]# service crond restart
停止 crond:                                               [确定]
启动 crond:                                               [确定]
[[email protected] ~]# chkconfig crond on
 
现在可以访问:http://web1.eyo.com/awstats/awstats.pl?config=www.eyo.com将出现的界面如下图:
 

但是使用上述地址访问awstats页面时,URL信息太长,可以做一个自动跳转的HTML网页,以简化输入:

[[email protected] ~]# vim /usr/local/apache2/htdocs/aw.html
<html>
<head>
<meta http-equiv=refresh content=”0;url=http://web2.eyo.com/awstats/awstats.pl?config=www.eyo.com”>
</head>
<body></body>
</html>
 

当访问http://web1.eyo.com/aw.html时,将自动跳转到awstats的日志分析报告页面,

在web2上进行以上全部同样的配置即可

 

 

2、在 web1、web2上分别部署phpMyAdmin

具体步骤为:
[[email protected] Desktop]# tar zxvf phpMyAdmin-2.11.9.5-all-languages.tar.gz

[[email protected] Desktop]# mv phpMyAdmin-2.11.9.5-all-languages phpMyAdmin
[[email protected] Desktop]# mv phpMyAdmin /usr/local/apache2/htdocs/
[[email protected] Desktop]# cd /usr/local/apache2/htdocs/phpMyAdmin/
[[email protected] phpMyAdmin]# cp config.sample.inc.php config.inc.php

[[email protected] phpMyAdmin]# vim config.inc.php (密码非空即可)

17  $cfg[‘blowfish_secret’] = ‘123’; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
 
访问http://web1.eyo.com/phpMyAdmin/,可以进入登录界面,使用MySQL数据库管理员的账户和密码进行登录即可
 

 

在phpMyAdmin的web页面下方,可能会出现“无法载入mcrypt扩展,请检查PHP配置”的错误提示信息,这是由于没有mcrypt加密算法扩展库造成的,可以忽略

 

 

3、部署MySQL的备份(web1和web2上都需进行

通过下面的脚本文件实现本地自动备份
 
#!/bin/sh
# File: /var/scripts/mysql.sh
# Database info
DB_NAME=”test”(如果是备份所有数据库,则可以不用定义此变量)
DB_USER=”root”
DB_PASS=”cssl#123″
 
# Others vars
BIN_DIR=”/usr/local/mysql/bin”
BCK_DIR=”/var/backup/mysql”
DATE=`date +%F`
 
#$BIN_DIR/mysqldump –opt -u$DB_USER -p$DB_PASS $DB_NAME | gzip > $BCK_DIR/db_$DATE-$DBNAME.sql.gz         (备份单一数据库)
$BIN_DIR/mysqldump –opt -u$DB_USER -p$DB_PASS –all-databases | gzip > $BCK_DIR/db_$DATE-all.sql.gz  (备份所有数据库)
 

[[email protected] ~]# mkdir -p  /var/backup/mysql
[[email protected] ~]# chmod a+x /var/scripts/mysql.sh
[[email protected] ~]# crontab -e

   30 5  * * * /var/scripts/mysql.sh (一般在闲时每天备份一次)
 

可以先进行一次测试:

[[email protected] ~]# /var/scripts/mysql.sh
[[email protected] ~]# ls /var/backup/mysql/

db_2011-07-11-all.sql.gz
 

以上的所有步骤在两台服务器上均需配置!

 

 

 

转载于:https://blog.51cto.com/linuxclub/608267

本文来源 互联网收集,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源,如您发现有涉嫌抄袭侵权的内容,请联系本站核实处理。

© 版权声明

相关文章