Monday, 29 de June de 2009

PHP整理显示照片exif信息(转)

HP整理显示照片exif信息,绝对好东西。

* 获取图象信息的函数
*
* 一个全面获取图象信息的函数
*
* @access public
* @param string $img 图片路径
* @return array

< ?php
/**
* 获取图象信息的函数
*
* 一个全面获取图象信息的函数
*
* @access public
* @param string $img 图片路径
* @return array
*/
function GetImageInfoVal($ImageInfo,$val_arr) {
    $InfoVal = “未知”;
    foreach($val_arr as $name=>$val) {
    if ($name==$ImageInfo) {
    $InfoVal = &$val;
    break;
    }
    }
    return $InfoVal;
}
function GetImageInfo($img) {
    
 
    
    $imgtype = array(”", “GIF”, “JPG”, “PNG”, “SWF”, “PSD”, “BMP”, “TIFF(intel byte order)”, “TIFF(motorola byte order)”, “JPC”, “JP2″, “JPX”, “JB2″, “SWC”, “IFF”, “WBMP”, “XBM”);
    $Orientation = array(”", “top left side”, “top right side”, “bottom right side”, “bottom left side”, “left side top”, “right side top”, “right side bottom”, “left side bottom”);
    $ResolutionUnit = array(”", “”, “英寸”, “厘米”);
    $YCbCrPositioning = array(”", “the center of pixel array”, “the datum point”);
    $ExposureProgram = array(”未定义”, “手动”, “标准程序”, “光圈先决”, “快门先决”, “景深先决”, “运动模式”, “肖像模式”, “风景模式”);
    $MeteringMode_arr = array(
    ”0″ => “未知”,
    ”1″ => “平均”,
    ”2″ => “中央重点平均测光”,
    ”3″ => “点测”,
    ”4″ => “分区”,
    ”5″ => “评估”,
    ”6″ => “局部”,
    ”255″ => “其他”
    );
    $Lightsource_arr = array(
    ”0″ => “未知”,
    ”1″ => “日光”,
    ”2″ => “荧光灯”,
    ”3″ => “钨丝灯”,
    ”10″ => “闪光灯”,
    ”17″ => “标准灯光A”,
    ”18″ => “标准灯光B”,
    ”19″ => “标准灯光C”,
    ”20″ => “D55″,
    ”21″ => “D65″,
    ”22″ => “D75″,
    ”255″ => “其他”
    );
    $Flash_arr = array(
    ”0″ => “flash did not fire”,
    ”1″ => “flash fired”,
    ”5″ => “flash fired but strobe return light not detected”,
    ”7″ => “flash fired and strobe return light detected”,
    );
    
    $exif = exif_read_data ($img,”IFD0″);
    if ($exif===false) {
    $new_img_info = array (”文件信息” => “没有图片EXIF信息”);
    }
    else
    {
    $exif = exif_read_data ($img,0,true);
    $new_img_info = array (
    ”文件信息” => “—————————–”,
    ”文件名” => $exif[FILE][FileName],
    ”文件类型” => $imgtype[$exif[FILE][FileType]],
    ”文件格式” => $exif[FILE][MimeType],
    ”文件大小” => $exif[FILE][FileSize],
    ”时间戳” => date(”Y-m-d H:i:s”,$exif[FILE][FileDateTime]),
    ”图像信息” => “—————————–”,
    ”图片说明” => $exif[IFD0][ImageDescription],
    ”制造商” => $exif[IFD0][Make],
    ”型号” => $exif[IFD0][Model],
    ”方向” => $Orientation[$exif[IFD0][Orientation]],
    ”水平分辨率” => $exif[IFD0][XResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]],
    ”垂直分辨率” => $exif[IFD0][YResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]],
    ”创建软件” => $exif[IFD0][Software],
    ”修改时间” => $exif[IFD0][DateTime],
    ”作者” => $exif[IFD0][Artist],
    ”YCbCr位置控制” => $YCbCrPositioning[$exif[IFD0][YCbCrPositioning]],
    ”版权” => $exif[IFD0][Copyright],
    ”摄影版权” => $exif[COMPUTED][Copyright.Photographer],
    ”编辑版权” => $exif[COMPUTED][Copyright.Editor],
    ”拍摄信息” => “—————————–”,
    ”Exif版本” => $exif[EXIF][ExifVersion],
    ”FlashPix版本” => “Ver. “.number_format($exif[EXIF][FlashPixVersion]/100,2),
    ”拍摄时间” => $exif[EXIF][DateTimeOriginal],
    ”数字化时间” => $exif[EXIF][DateTimeDigitized],
    ”拍摄分辨率高” => $exif[COMPUTED][Height],
    ”拍摄分辨率宽” => $exif[COMPUTED][Width],
    /*
    The actual aperture value of lens when the image was taken.
    Unit is APEX.
    To convert this value to ordinary F-number(F-stop),
    calculate this value’s power of root 2 (=1.4142).
    For example, if the ApertureValue is ‘5′, F-number is pow(1.41425,5) = F5.6.
    */
    ”光圈” => $exif[EXIF][ApertureValue],
    ”快门速度” => $exif[EXIF][ShutterSpeedValue],
    ”快门光圈” => $exif[COMPUTED][ApertureFNumber],
    ”最大光圈值” => “F”.$exif[EXIF][MaxApertureValue],
    ”曝光时间” => $exif[EXIF][ExposureTime],
    ”F-Number” => $exif[EXIF][FNumber],
    ”测光模式” => GetImageInfoVal($exif[EXIF][MeteringMode],$MeteringMode_arr),
    ”光源” => GetImageInfoVal($exif[EXIF][LightSource], $Lightsource_arr),
    ”闪光灯” => GetImageInfoVal($exif[EXIF][Flash], $Flash_arr),
    ”曝光模式” => ($exif[EXIF][ExposureMode]==1?”手动”:”自动”),
    ”白平衡” => ($exif[EXIF][WhiteBalance]==1?”手动”:”自动”),
    ”曝光程序” => $ExposureProgram[$exif[EXIF][ExposureProgram]],
    /*
    Brightness of taken subject, unit is APEX. To calculate Exposure(Ev) from BrigtnessValue(Bv), you must add SensitivityValue(Sv).
    Ev=Bv+Sv Sv=log((ISOSpeedRating/3.125),2)
    ISO100:Sv=5, ISO200:Sv=6, ISO400:Sv=7, ISO125:Sv=5.32. 
    */
    ”曝光补偿” => $exif[EXIF][ExposureBiasValue].”EV”,
    ”ISO感光度” => $exif[EXIF][ISOSpeedRatings],
    ”分量配置” => (bin2hex($exif[EXIF][ComponentsConfiguration])==”01020300″?”YCbCr”:”RGB”),//’0×04,0×05,0×06,0×00′=”RGB” ‘0×01,0×02,0×03,0×00′=”YCbCr”
    ”图像压缩率” => $exif[EXIF][CompressedBitsPerPixel].”Bits/Pixel”,
    ”对焦距离” => $exif[COMPUTED][FocusDistance].”m”,
    ”焦距” => $exif[EXIF][FocalLength].”mm”,
    ”等价35mm焦距” => $exif[EXIF][FocalLengthIn35mmFilm].”mm”,
    /*
    Stores user comment. This tag allows to use two-byte character code or unicode. First 8 bytes describe the character code. ‘JIS’ is a Japanese character code (known as Kanji).
    ’0×41,0×53,0×43,0×49,0×49,0×00,0×00,0×00′:ASCII
    ’0×4a,0×49,0×53,0×00,0×00,0×00,0×00,0×00′:JIS
    ’0×55,0×4e,0×49,0×43,0×4f,0×44,0×45,0×00′:Unicode
    ’0×00,0×00,0×00,0×00,0×00,0×00,0×00,0×00′:Undefined
    */
    ”用户注释编码” => $exif[COMPUTED][UserCommentEncoding],
    ”用户注释” => $exif[COMPUTED][UserComment],
    ”色彩空间” => ($exif[EXIF][ColorSpace]==1?”sRGB”:”Uncalibrated”),
    ”Exif图像宽度” => $exif[EXIF][ExifImageLength],
    ”Exif图像高度” => $exif[EXIF][ExifImageWidth],
    ”文件来源” => (bin2hex($exif[EXIF][FileSource])==0×03?”digital still camera”:”unknown”),
    ”场景类型” => (bin2hex($exif[EXIF][SceneType])==0×01?”A directly photographed image”:”unknown”),
    ”缩略图文件格式” => $exif[COMPUTED][Thumbnail.FileType],
    ”缩略图Mime格式” => $exif[COMPUTED][Thumbnail.MimeType]
    );
    }
    return $new_img_info;
}
 
$innerhtml = “”;
$exif = GetImageInfo($_GET[’img’]);
$innerhtml .= “<table>”;
 
foreach($exif as $name=>$val) {
    $innerhtml .= “<tr><td>{$name}</td><td>{$val}</td></tr>”;
}
 
$innerhtml .= “<tr><td colspan=\”2\”>”;
if ($_GET[’img’]) {
    $image = exif_thumbnail($_GET[’img’]);
} else {
    $image = false;
}
if ($image!==false) {
    $innerhtml .= “<img src=\”thumbnail.php?img=”.$_GET[’img’].”\”/>”;
} else {
    // no thumbnail available, handle the error here
    $innerhtml .= “No thumbnail available”;
}
 
$innerhtml .= “</td></tr></table>”;
?>
<html>
<head> 
<title>图片信息</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=??????”>
</meta></head>
<body>
<script>
<!–
//初始化内容值
parent.followTd<?=$_GET[’r_id’];?>.innerHTML=’< ?=$innerhtml;?>’;
//已读取
parent.document.images.followImg< ?=$_GET[’r_id’];?>.loaded=’yes’;
–>
</script>
</body>
</html>


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=158

发表一篇回复 » 文章所属分类为 php by LanCao at 15:06.

回到页头

Tuesday, 16 de June de 2009

招募拥有LAMP经验1年以上开发人员 工作地上海

如题,有意请发送简历至 jiajun_lu@163.com


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=157

1 回复 » 文章所属分类为 其他 by LanCao at 16:01.

回到页头

Wednesday, 10 de June de 2009

Linux查看系统配置常用命令

系统

# uname -a               # 查看内核/操作系统/CPU信息
# head -n 1 /etc/issue   # 查看操作系统版本
# cat /proc/cpuinfo      # 查看CPU信息
# hostname               # 查看计算机名
# lspci -tv              # 列出所有PCI设备
# lsusb -tv              # 列出所有USB设备
# lsmod                  # 列出加载的内核模块
# env                    # 查看环境变量

资源

# free -m                # 查看内存使用量和交换区使用量
# df -h                  # 查看各分区使用情况
# du -sh <目录名>        # 查看指定目录的大小
# grep MemTotal /proc/meminfo   # 查看内存总量
# grep MemFree /proc/meminfo    # 查看空闲内存量
# uptime                 # 查看系统运行时间、用户数、负载
# cat /proc/loadavg      # 查看系统负载

磁盘和分区

# mount | column -t      # 查看挂接的分区状态
# fdisk -l               # 查看所有分区
# swapon -s              # 查看所有交换分区
# hdparm -i /dev/hda     # 查看磁盘参数(仅适用于IDE设备)
# dmesg | grep IDE       # 查看启动时IDE设备检测状况

网络

# ifconfig               # 查看所有网络接口的属性
# iptables -L            # 查看防火墙设置
# route -n               # 查看路由表
# netstat -lntp          # 查看所有监听端口
# netstat -antp          # 查看所有已经建立的连接
# netstat -s             # 查看网络统计信息

进程

# ps -ef                 # 查看所有进程
# top                    # 实时显示进程状态

用户

# w                      # 查看活动用户
# id <用户名>            # 查看指定用户信息
# last                   # 查看用户登录日志
# cut -d: -f1 /etc/passwd   # 查看系统所有用户
# cut -d: -f1 /etc/group    # 查看系统所有组
# crontab -l             # 查看当前用户的计划任务

服务

# chkconfig –list       # 列出所有系统服务
# chkconfig –list | grep on    # 列出所有启动的系统服务

程序

# rpm -qa                # 查看所有安装的软件包


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=156

发表一篇回复 » 文章所属分类为 Linux by LanCao at 12:30.

回到页头

Friday, 5 de June de 2009

Ubuntu下MySQL不能远程登录的解决(转)

Q: 当在另一台机器上登录MySQL时出现如下错误:

ERROR 2003 (HY000): Can’t connect to MySQL server on ‘x.x.x.x’ (111)

A: 原因是MySQL考虑到安全因素,默认配置只让从本地登录

打开 /etc/mysql/my.cnf 文件,找到 bind-address = 127.0.0.1 修改为 bind-address = 0.0.0.0

重启mysql : sudo /etc/init.d/mysql restart

可参考:

> I’ve already check my /etc/my.cnf file for a “binding”
> line. Its not 
> there. I also found an item online that indicated
> adding:
>

Look for the option “skip-networking”. This disables TCP/IP so the 
server only accepts local connections via the Unix socket. This sounds 
like your situation.
Note that a “could not connect” error means just that. If the problem 
was related to user privileges you would get an “access denied” error.

Q: 还一种情况出现类似下面的错误:

ERROR 1045 (28000): Access denied for user ‘test’@'x.x.x.x’ (using password: NO)

A: 原因是没有给登录用户名设置远程主机登录的权限。

在本地用 root 登录: mysql -u root -p

修改 MySQL 数据库中 user 表中 对应用户名的 Host 字段,将 localhost 改为 %

use mysql;

update user set Host = ‘%’ where User = ‘username’;


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=155

发表一篇回复 » 文章所属分类为 数据库 by LanCao at 16:08.

回到页头

Thursday, 4 de June de 2009

Ubuntu 8.04 系统安装APACHE PHP MYSQL(转)

1、安装 Apache2+PHP5+MySQL

sudo apt-get install apache2 libapache2-mod-phpphpphp5-gd mysql-server php5-mysql phpmyadmin

joelhy 提醒 这一步可以使用新立得来安装,同样效果。

打开新立得,编辑 –> 使用任务分组标记软件包 –> 勾选 LAMP Server

然后再单独安装 phpmyadmin

sudo apt-get install phpmyadmin

2、启用 mod_rewrite 模块

sudo a2enmod rewrite

3、配置 apache2.conf

sudo gedit /etc/apache2/apache2.conf

去掉 AddHandler cgi-script .cgi 前的注释 “#”。

然后在任意地方添加这么一段:

<Virtualhost localhost>
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/cgi-bin/>
Options ExecCGI
</Directory>
</Virtualhost>重启服务器

sudo /etc/init.d/apache2 restart

搞定。

说明:PHP 程序放 /var/www/ 下面都可以,CGI 程序放 /var/www/cgi-bin/ 下面。

是不是太简单了,除去下载的时间,要不了一分钟就可以完成配置,在 Ubuntu 上还需要 APM 包吗?还是记住以下几个命令和位置就行了。

sudo /etc/init.d/apache2 restart (重启 apache)

sudo gedit /etc/php5/apache2/php.ini (配置 php.ini)

sudo gedit /etc/apache2/apache2.conf (配置 apache2.conf)

/var/www/(主目录位置)

Q: ERROR 1130 (00000): Host X is not allowed to connect to this MySQL server

A: 这种问题一般出现在远程登录数据库的时候。原因是由于连接mysql数据库的用户名的权限不够,可以在服务器上用root用户登录,查看mysql数据库的user表,修改对应用户的host列的值为%(默认的为localhost)。相应的sql语句为:
use mysql;
update user set host=’%’ where user=’connect name‘;
flush privileges;
exit

Q: Ubuntu 下安装phpmyadmin 却无法使用

A: 安装phpmyadmin命令:sudo apt-get install phpmyadmin
默认安装在 /usr/share/phpmyadmin
作个链接到 /var/www/ 目录下,命令为:sudo ln -s /usr/share/phpmyadmin/ /var/www/
再使用 http://localhost/phpmyadmin 即可以访问了。

Q: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

A:这是一个 warning,出现在apache2启动或重起时。主要是因为在配置 apache2 时,没有指定相应的主机名,即 ServerName。修改 /etc/apache2/httpd.conf , 在最前加入 ServerName localhost:80 即可。

Q: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

A:这是由于在页面中使用 session_start() 的位置没有放对,按官方文档的说法:If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser
所以,可以把<?php session_start();?>放在页面的最前面即可,注意<?php 前不要有空格。

Q: Warning: Cannot modify header information - headers already sent

A:由于在页面中使用了 header() ,按官方文档 的说法: Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
另外对于 header(”Location:”) 的用法,在下一行用exit;以使后面的内容不会被执行。
如:
<?php
header("Location: http://www.example.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=154

发表一篇回复 » 文章所属分类为 Linux by LanCao at 13:49.

回到页头

Thursday, 4 de June de 2009

Ubuntu:关机命令详解(转)

Linux系统中的关机命令 
几种关机方式,什么shutdown,reboot,init..都有都有。。 

Tags: linux 关机 shotdonw reboot init halt 
在Linux下一些常用的关机/重启命令有shutdown、halt、reboot、及init,它们都可以达到重启系统的目的,但每个命令的内部工作过程是不同的,通过本文的介绍,希望你可以更加灵活的运用各种关机命令。 
  
1.shutdown 
  
shutdown命令安全地将系统关机。有些用户会使用直接断掉电源的方式来关闭linux,这是十分危险的。因为linux与windows不同,其后台运行着许多进程,所以强制关机可能会导致进程的数据丢失﹐使系统处于不稳定的状态﹐甚至在有的系统中会损坏硬件设备。而在系统关机前使用shutdown命令﹐系统管理员会通知所有登录的用户系统将要关闭。并且login指令会被冻结﹐即新的用户不能再登录。直接关机或者延迟一定的时间才关机都是可能的﹐还可能重启。这是由所有进程〔process〕都会收到系统所送达的信号〔signal决定的。这让像vi之类的程序有时间储存目前正在编辑的文档﹐而像处理邮件〔mail〕和新闻〔news〕的程序则可以正常地离开等等。 
  
shutdown执行它的工作是送信号〔signal〕给init程序﹐要求它改变runlevel。Runlevel 0被用来停机〔halt〕﹐runlevel 6是用来重新激活〔reboot〕系统﹐而runlevel 1则是被用来让系统进入管理工作可以进行的状态﹔这是预设的﹐假定没有-h也没有-r参数给shutdown。要想了解在停机〔halt〕或者重新开机〔reboot〕过程中做了哪些动作﹐你可以在这个文件/etc/inittab里看到这些runlevels相关的资料。 
  
shutdown 参数说明: 
  
[-t] 在改变到其它runlevel之前﹐告诉init多久以后关机。 
  
[-r] 重启计算器。 
  
[-k] 并不真正关机﹐只是送警告信号给每位登录者〔login〕。 
  
[-h] 关机后关闭电源〔halt〕。 
  
[-n] 不用init﹐而是自己来关机。不鼓励使用这个选项﹐而且该选项所产生的后果往往不总是你所预期得到的。 
  
[-c] cancel current process取消目前正在执行的关机程序。所以这个选项当然没有时间参数﹐但是可以输入一个用来解释的讯息﹐而这信息将会送到每位使用者。 
  
[-f] 在重启计算器〔reboot〕时忽略fsck。 
  
[-F] 在重启计算器〔reboot〕时强迫fsck。 
  
[-time] 设定关机〔shutdown〕前的时间。 
  
2.halt—-最简单的关机命令 
  
其实halt就是调用shutdown -h。halt执行时﹐杀死应用进程﹐执行sync系统调用﹐文件系统写操作完成后就会停止内核。 
  
参数说明: 
  
[-n] 防止sync系统调用﹐它用在用fsck修补根分区之后﹐以阻止内核用老版本的超级块〔superblock〕覆盖修补过的超级块。 
  
[-w] 并不是真正的重启或关机﹐只是写wtmp〔/var/log/wtmp〕纪录。 
  
[-d] 不写wtmp纪录〔已包含在选项[-n]中〕。 
  
[-f] 没有调用shutdown而强制关机或重启。 
  
[-i] 关机〔或重启〕前﹐关掉所有的网络接口。 
  
[-p] 该选项为缺省选项。就是关机时调用poweroff。 
  
3.reboot 
  
reboot的工作过程差不多跟halt一样﹐不过它是引发主机重启﹐而halt是关机。它的参数与halt相差不多。 
  
4.init 
  
init是所有进程的祖先﹐它的进程号始终为1﹐所以发送TERM信号给init会终止所有的用户进程﹑守护进程等。shutdown 就是使用这种机制。init定义了8个运行级别(runlevel),init 0为关机﹐init 1为重启。关于init可以长篇大论﹐这里就不再叙述。另外还有telinit命令可以改变init的运行级别﹐比如﹐telinit -iS可使系统进入单用户模式﹐并且得不到使用shutdown时的信息和等待时间。


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=153

发表一篇回复 » 文章所属分类为 Linux by LanCao at 12:48.

回到页头

Wednesday, 3 de June de 2009

AWStats与cronolog分析apache的LOG日志(转)

参考多个人的文档
http://bbs.chinaunix.net/viewthread.php?tid=613098
http://www.ieasy.org/coffee/archives/cat_technology_related.html

1.apache安装

apache安装

#wget http://archive.apache.org/dist/httpd/httpd-2.0.54.tar.gz
#tar xzvf httpd-2.0.54.tar.gz
#./configure –prefix=/usr/local/apache –with-mpm=worker –enable-so –enable-ssl –enable-mods-shared=all

2.cronolog 安装,请参考我写的上一篇文章
http://blog.chinaunix.net/article.php?articleId=63868&blogId=2898

 

3.AWStats安装
AWStats 官方网站:http://awstats.sourceforge.net/
下载最新的版本
#老版有漏洞^-^
wget http://awstats.sourceforge.net/files/awstats-6.5.tar.gz
tar awstats-6.5.tar.gz
mv awstats-6.5 /usr/local/awstats
cd /usr/local/awstats/tools

4.配置
#直接分析 apache log 的 AWStats 设定的LOG 
#直接在此目录执行
perl awstats_configure.pl

 

QUOTE:

—– AWStats awstats_configure 1.0 (build 1.3) (c) Laurent Destailleur —–
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to ‘understand’ all possible ways to use AWStats…
Read the AWStats documentation (docs/index.html). 
—–>; Running OS detected: Linux, BSD or Unix
—–>; Check for web server install 

Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:Program filesapache groupapacheconfhttpd.conf
Config file path (’none’ to skip web server setup):

>;/etc/httpd/conf/httpd.conf

#输入apache 的配置文件目录
—–>; Check and complete web server config file ‘/usr/local/apache

  AWStats directives already present. 

—–>; Update model config file ‘/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf’
  File awstats.model.conf updated. 

—–>; Need to create a new config file ?
Do you want me to build a new AWStats config/profile

file (required if first install) [y/N] ? y

#输入 y,确定产生 AWStats配置文件

—–>; Define config file name to create

What is the name of your web site or profile analysis ?

Example: www.mysite.com
Example: demo

Your web site, virtual server or profile name:
>; www
#输入 www,为配置文件最名字,此可自取 

—–>; Define config file path

In which directory do you plan to store your config file(s) ?

Default: /etc/awstats

Directory path to store config file(s) (Enter for default):

>;
#直接按下 Enter,
—–>; Create config file ‘/etc/awstats/awstats.www.conf’

Config file /etc/awstats/awstats.www.conf created. 

—–>; Restart Web server with ‘/sbin/service httpd restart’

停止 httpd:                                                [  确定  ]

启动 httpd:                                                [  确定  ]
—->; Add update process inside a scheduler

Sorry, configure.pl does not support automatic add to cron yet.

You can do it manually by adding the following command to your cron:

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www

Or if you have several config files and prefer having only one command:

/usr/local/awstats/tools/awstats_updateall.pl now

Press ENTER to continue…

#按下 Enter 继续,按两次

chmod 755 /usr/local/awstats

mkdir /var/lib/awstats

#修改配置文件

cp /etc/awstats/awstats.www.conf /etc/awstats/awstats.www.conf.bak
#备份配置文件
vi /etc/awstats/awstats.www.conf

QUOTE:

51行 LogFile=”/var/log/httpd/mylog.log” 修改成–>; /LogFile=”/usr/local/apache/logs/960it_access_log.%YYYY-24%MM-24%DD.log”
#修改你的LOG文件及目录,配合cronolog 和cron分析当天的日志
147行 SiteDomain=”www” 修改成–>; SiteDomain=”你的域名”

182行 DNSLookup=2 修改成–>; DNSLookup=1

/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www -update

#上面一句要特別注意,台果你的系統先前产生大量大量的log,请等候!不要按ctal+c結束

#awstats默认会把系统默认安装的apache启动,如果你不是用这个请先把停止.

/etc/rc.d/init.d/httpd stop

/usr/local/apache/bin/apachectl  restart
测试:http://IP/awstats/awstats.pl?config=www

#定時更新
crontab -uroot -e
#在此文件的最后增加,设置成每天晚上23:50分析当天的LOG

QUOTE:

50 23 * * * root /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www -update >;/dev/null 2>;

5.安全

保护/db/htdocs/www/awstat/禁止未授权用户访问 
修改
#vi /usr/local/apache/conf/httpd.conf

<Directory “/usr/local/awstats/wwwroot/www”>
   AuthType Basic
  AuthName “Restricted Files”
  AuthUserFile /usr/local/apache/passwd/passwords
  Require user loguser
</Directory>

其中在 /usr/local/apache/passwd/下产生passwords 的密码文件
运行如下代码产生用户名为loguser用户及其密码

 

 以上的设置由于要cgi支持,也增加了安全隐患可以用awstats 自带的awstats_buildstaticpages.pl来 生成静态页面 可以添加到crontab中

  50 23 * * * * /usr/local/awstats/tools/awstats_buildstaticpages.pl -update -config=www. -lang=cn -dir=/db/htdocs/www/awstat/ -awstatsprog=/usr/local/awstats/wwwroot/cgi-bin/awstats.pl

  如果www.abc.net 虚拟主机 主目录为/db/htdocs/www/ 则在浏览器中输入http://www.abc.net/awstat/awstats.www.abc.net.html 就可以通过认真访问静态页面

6.增加中awstats 显示来访者位置的插件 qqhostinfo

首先,点击这里下载插件。把它放在awstats/wwwroot/cgi-bin/plugins中。

其次,下载上一篇blog提到的分析QQWry.dat的perl脚本

然后放在同一目录,去网上下载QQWry.Dat放在同一目录中,注意文件名一定要是QQWry.Dat,实际上是我用我的珊瑚版本的QQ的这个文件.

再编辑你得awstats配置文件,大概在LoadPlugin=”hostinfo”的后面增加一行
LoadPlugin=”qqhostinfo”
最后
 vi /usr/local/awstats/wwwroot/cgi-bin/plugins/qqhostinfo.pm
第17行

require的路径改

require “/usr/local/awstats/wwwroot/cgi-bin/plugins/qqwry.pl”;


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=152

发表一篇回复 » 文章所属分类为 apache by LanCao at 17:23.

回到页头

Tuesday, 2 de June de 2009

RHEL5系统 apache-2.2.11 + php-5.2.8 + mysql-5.1.30(转)

1。安装apache-2.2.11
./configure
make
make install

然后在 ~/.bash_profile 文件中添加
PATH=$PATHHOME/bin:/usr/local/apache2/bin
这样为了方便启用、关闭apache

2。安装mysql(mysql-5.1.30-linux-i686-icc-glibc23.tar.gz)
这里采用的是mysql的二进制版本(32位),并为Intel构架优化过的
参考:[url]http://dev.mysql.com/doc/refman/5.1/en/installing-binary.html[/url]

【备注】
刚开始这个版本在 rhel5 上运行 scripts/mysql_install_db –user=mysql 失败
改用版本 mysql-5.0.67-linux-i686-icc-glibc23.tar.gz 安装正常,后来发现在
/var/lib/mysql 目录下有以前5.0版本的数据,可能由于兼容性导致5.1版本安装不正常,
于是我将原来的数据删除即可正常安装 5.1 版本。

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db –user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe –user=mysql &

——————————————————————————–

[root@miix mysql]# scripts/mysql_install_db –user=mysql
Installing MySQL system tables…
OK
Filling help tables…
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password ‘new-password’
./bin/mysqladmin -u root -h miix.hoho.com password ‘new-password’

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available at [url]http://www.mysql.com/[/url]
Support MySQL by buying support/licenses from [url]http://shop.mysql.com/[/url]
——————————————————————————–

安装完毕后根据以上的提示,别忘了设置mysql root用户密码,我另外新建一个用户 zhaozh
mysql> grant all on *.* to zhaozh@localhost identified by ‘××××××’

3。安装php-5.2.8

./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql –with-mysqli –with-gd –with-jpeg-dir –with-png-dir
make
make install

cp php.ini-dist /usr/local/lib/php.ini

php安装完后,在 /usr/local/apache2/modules 添加了动态连接库 libphp5.so

如果在启动或者重启apache时候,出现以下信息:
[root@miix htdocs]# apachectl -k restart
httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

这是由于selinux引起的,所以需要这样一下:
chcon -t textrel_shlib_t libphp5.so

php安装完后,在 /usr/local/apache2/conf/httpd.conf 添加了一行:
LoadModule php5_module        modules/libphp5.so

本人不想采用这种方式,于是将上述一行注释掉,然后在 httpd.conf 文件末尾添加:
Include conf/conf.d/*.conf

接着建立目录 /usr/local/apache2/conf/conf.d 
添加 php.conf 文件,内容如下:

——————————————————————————–
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#

LoadModule php5_module modules/libphp5.so

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps

——————————————————————————–

重启apache,在 /usr/local/apache2/htdocs 目录下建立一个 test.php 文件,如下
<?php phpinfo(); ?>

在浏览器输入 [url]http://ip/test.php[/url] ,如果能正常显示出php信息则说明apache+php OK了。

——————————————————————————————

赵小蜗牛

QQ: 755721501

E-mail: snailwarrior@qq.com

在不断奉献中谋求生存发展、打造自己的优秀品质,用人性最本质最动人的一面“营销”自己!

本文出自 “小蜗牛技术之家” 博客,请务必保留此出处http://snailwarrior.blog.51cto.com/680306/137690
 


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=151

发表一篇回复 » 文章所属分类为 Linux by LanCao at 18:35.

回到页头

Tuesday, 2 de June de 2009

Linux 安装 Mysql(转)

一、引言  想使用Linux已经很长时间了,由于没有硬性任务一直也没有系统学习,近日由于工作需要必须使用Linux下的MySQL。本以为有Windows下使用SQL Server的经验,觉得在Linux下安装MySql应该是易如反掌的事,可在真正安装和使用MySQL时走了很多弯路,遇见很多问题,毕竟Linux 和Windows本身就有很大区别。为了让和我一样的初学者在学习的过程中少走弯路,尽快入门,写了此文,希望对您有所帮助。本文的Linux环境是 Red Hat 9.0,MySQL是4.0.16。

   二、安装Mysql

   1、下载MySQL的安装文件

   安装MySQL需要下面两个文件:

   MySQL-server-4.0.16-0.i386.rpm   

   MySQL-client-4.0.16-0.i386.rpm

   下载地址为:www.mysql.com/downloads/mysql-4.0.html,打开此网页,下拉网页找到“Linux x86 RPM downloads”项,找到“Server”和“Client programs”项,下载需要的上述两个rpm文件。

   2、安装MySQL

   rpm文件是Red Hat公司开发的软件安装包,rpm可让Linux在安装软件包时免除许多复杂的手续。该命令在安装时常用的参数是 –ivh ,其中i表示将安装指定的rmp软件包,V表示安装时的详细信息,h表示在安装期间出现“#”符号来显示目前的安装过程。这个符号将持续到安装完成后才停止。

   1)安装服务器端

   在有两个rmp文件的目录下运行如下命令:

   [root@test1 local]# rpm -ivh MySQL-server-4.0.16-0.i386.rpm

   显示如下信息。

  warning: MySQL-server-4.0.16-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

   Preparing…       ########################################### [100%]

   1:MySQL-server     ########################################### [100%]

  。。。。。。(省略显示)

   /usr/bin/mysqladmin -u root password \’new-password\’

   /usr/bin/mysqladmin -u root -h test1 password \’new-password\’

  。。。。。。(省略显示)

   Starting mysqld daemon with databases from /var/lib/mysql

   如出现如上信息,服务端安装完毕。测试是否成功可运行netstat看Mysql端口是否打开,如打开表示服务已经启动,安装成功。Mysql默认的端口是3306。

   [root@test1 local]# netstat -nat

   Active Internet connections (servers and established)

   Proto Recv-Q Send-Q Local Address    Foreign Address   State   

   tcp  0  0 0.0.0.0:3306   0.0.0.0:*    LISTEN   

   上面显示可以看出MySQL服务已经启动。

   2)安装客户端

   运行如下命令:

   [root@test1 local]# rpm -ivh MySQL-client-4.0.16-0.i386.rpm

   warning: MySQL-client-4.0.16-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5

   Preparing…    ########################################### [100%]

   1:MySQL-client########################################### [100%]

   显示安装完毕。

   用下面的命令连接mysql,测试是否成功。

  三、登录MySQL

   登录MySQL的命令是mysql, mysql 的使用语法如下:

   mysql [-u username] [-h host] [-p[password]] [dbname]

   username 与 password 分别是 MySQL 的用户名与密码,mysql的初始管理帐号是root,没有密码,注意:这个root用户不是Linux的系统用户。MySQL默认用户是root,由于初始没有密码,第一次进时只需键入mysql即可。

   [root@test1 local]# mysql

   Welcome to the MySQL monitor. Commands end with ; or \\g.

   Your MySQL connection id is 1 to server version: 4.0.16-standard

   Type \’help;\’ or \’\\h\’ for help. Type \’\\c\’ to clear the buffer.

   mysql>

   出现了“mysql>”提示符,恭喜你,安装成功!

   增加了密码后的登录格式如下:

   mysql -u root -p

   Enter password: (输入密码)

   其中-u后跟的是用户名,-p要求输入密码,回车后在输入密码处输入密码。

   注意:这个mysql文件在/usr/bin目录下,与后面讲的启动文件/etc/init.d/mysql不是一个文件。

   四、MySQL的几个重要目录

   MySQL安装完成后不象SQL Server默认安装在一个目录,它的数据库文件、配置文件和命令文件分别在不同的目录,了解这些目录非常重要,尤其对于Linux的初学者,因为 Linux本身的目录结构就比较复杂,如果搞不清楚MySQL的安装目录那就无从谈起深入学习。

   下面就介绍一下这几个目录。

   1、数据库目录

   /var/lib/mysql/

   2、配置文件

   /usr/share/mysql(mysql.server命令及配置文件)

   3、相关命令

   /usr/bin(mysqladmin mysqldump等命令)

   4、启动脚本

   /etc/rc.d/init.d/(启动脚本文件mysql的目录)

  五、修改登录密码

   MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。

   1、命令

   usr/bin/mysqladmin -u root password \’new-password\’

   格式:mysqladmin -u用户名 -p旧密码 password 新密码

   2、例子

   例1:给root加个密码123456。

   键入以下命令 :

   [root@test1 local]# /usr/bin/mysqladmin -u root password 123456

   注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。

   3、测试是否修改成功

   1)不用密码登录

   [root@test1 local]# mysql

   ERROR 1045: Access denied for user: \’root@localhost\’ (Using password: NO)

   显示错误,说明密码已经修改。

   2)用修改后的密码登录

   [root@test1 local]# mysql -u root -p

   Enter password: (输入修改后的密码123456)

   Welcome to the MySQL monitor. Commands end with ; or \\g.

   Your MySQL connection id is 4 to server version: 4.0.16-standard

   Type \’help;\’ or \’\\h\’ for help. Type \’\\c\’ to clear the buffer.

   mysql>

   成功!

   这是通过mysqladmin命令修改口令,也可通过修改库来更改口令。

   六、启动与停止

   1、启动

   MySQL安装完成后启动文件mysql在/etc/init.d目录下,在需要启动时运行下面命令即可。

   [root@test1 init.d]# /etc/init.d/mysql start

   2、停止

   /usr/bin/mysqladmin -u root -p shutdown

   3、自动启动

   1)察看mysql是否在自动启动列表中

   [root@test1 local]# /sbin/chkconfig –list

   2)把MySQL添加到你系统的启动服务组里面去

   [root@test1 local]# /sbin/chkconfig – add mysql

   3)把MySQL从启动服务组里面删除。

   [root@test1 local]# /sbin/chkconfig – del mysql

  七、更改MySQL目录

   MySQL默认的数据文件存储目录为/var/lib/mysql。假如要把目录移到/home/data下需要进行下面几步:

   1、home目录下建立data目录

   cd /home

   mkdir data

   2、把MySQL服务进程停掉:

   mysqladmin -u root -p shutdown

   3、把/var/lib/mysql整个目录移到/home/data

   mv /var/lib/mysql /home/data/

   这样就把MySQL的数据文件移动到了/home/data/mysql下

   4、找到my.cnf配置文件

   如果/etc/目录下没有my.cnf配置文件,请到/usr/share/mysql/下找到*.cnf文件,拷贝其中一个到/etc/并改名为my.cnf)中。命令如下:

   [root@test1 mysql]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

   5、编辑MySQL的配置文件/etc/my.cnf

   为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置。 修改socket=/var/lib/mysql/mysql.sock一行中等号右边的值为:/home/mysql/mysql.sock 。操作如下:

   vimy.cnf  (用vi工具编辑my.cnf文件,找到下列数据修改之)

   # The MySQL server

  [mysqld]

  port   = 3306

  #socket= /var/lib/mysql/mysql.sock(原内容,为了更稳妥用“#”注释此行)

  socket= /home/data/mysql/mysql.sock   (加上此行)

   6、修改MySQL启动脚本/etc/rc.d/init.d/mysql

   最后,需要修改MySQL启动脚本/etc/rc.d/init.d/mysql,把其中datadir=/var/lib/mysql一行中,等号右边的路径改成你现在的实际存放路径:home/data/mysql。

   [root@test1 etc]# vi /etc/rc.d/init.d/mysql

   #datadir=/var/lib/mysql    (注释此行)

   datadir=/home/data/mysql (加上此行)

   7、重新启动MySQL服务

   /etc/rc.d/init.d/mysql start

   或用reboot命令重启Linux

   如果工作正常移动就成功了,否则对照前面的7步再检查一下。

   八、MySQL的常用操作

   注意:MySQL中每个命令后都要以分号;结尾。

   1、显示数据库

   mysql> show databases;

   +———-+

   | Database |

   +———-+

   | mysql  |

   | test |

   +———-+

   2 rows in set (0.04 sec)

   Mysql刚安装完有两个数据库:mysql和test。mysql库非常重要,它里面有MySQL的系统信息,我们改密码和新增用户,实际上就是用这个库中的相关表进行操作。

   2、显示数据库中的表

   mysql> use mysql; (打开库,对每个库进行操作就要打开此库,类似于foxpro )

   Database changed

   mysql> show tables;

   +—————–+

   | Tables_in_mysql |

   +—————–+

   | columns_priv  |

   | db       |

   | func      |

   | host      |

   | tables_priv |

   | user      |

   +—————–+

   6 rows in set (0.01 sec)

   3、显示数据表的结构:

   describe 表名;

   4、显示表中的记录:

   select * from 表名;

   例如:显示mysql库中user表中的纪录。所有能对MySQL用户操作的用户都在此表中。

   Select * from user;

   5、建库:

   create database 库名;

   例如:创建一个名字位aaa的库

   mysql> create databases aaa;

  6、建表:

   use 库名;

   create table 表名 (字段设定列表);

   例如:在刚创建的aaa库中建立表name,表中有id(序号,自动增长),xm(姓名),xb(性别),csny(出身年月)四个字段

   use aaa;

   mysql> create table name (id int(3) auto_increment not null primary key, xm char(8),xb char(2),csny date);

   可以用describe命令察看刚建立的表结构。

   mysql> describe name;

   +——-+———+——+—–+———+—————-+

   | Field | Type  | Null | Key | Default | Extra     |

   +——-+———+——+—–+———+—————-+

   | id  | int(3) |   | PRI | NULL  | auto_increment |

   | xm  | char(8) | YES | | NULL  |        |

   | xb  | char(2) | YES | | NULL  |        |

   | csny | date  | YES | | NULL  |        |

   +——-+———+——+—–+———+—————-+

   7、增加记录

   例如:增加几条相关纪录。

   mysql> insert into name values(\’\',\’张三\’,\’男\’,\’1971-10-01\’);

   mysql> insert into name values(\’\',\’白云\’,\’女\’,\’1972-05-20\’);

   可用select命令来验证结果。

   mysql> select * from name;

   +—-+——+——+————+

   | id | xm| xb| csny  |

   +—-+——+——+————+

   | 1 | 张三 | 男| 1971-10-01 |

   | 2 | 白云 | 女| 1972-05-20 |

   +—-+——+——+————+

   8、修改纪录

   例如:将张三的出生年月改为1971-01-10

   mysql> update name set csny=\’1971-01-10\’ where xm=\’张三\’;

   9、删除纪录

   例如:删除张三的纪录。

   mysql> delete from name where xm=\’张三\’;

   10、删库和删表

   drop database 库名;

   drop table 表名;

   九、增加MySQL用户

   格式:grant select on 数据库.* to 用户名@登录主机 identified by “密码”

  例1、增加一个用户user_1密码为123,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入MySQL,然后键入以下命令:

   mysql> grant select,insert,update,delete on *.* to user_1@”%” Identified by “123″;

  例1增加的用户是十分危险的,如果知道了user_1的密码,那么他就可以在网上的任何一台电脑上登录你的MySQL数据库并对你的数据为所欲为了,解决办法见例2。

  例2、增加一个用户user_2密码为123,让此用户只可以在localhost上登录,并可以对数据库aaa进行查询、插入、修改、删除的操作(localhost指本地主机,即MySQL数据库所在的那台主机),这样用户即使用知道user_2的密码,他也无法从网上直接访问数据库,只能通过 MYSQL主机来操作aaa库。

   mysql>grant select,insert,update,delete on aaa.* to user_2@localhost identified by “123″;

   用新增的用户如果登录不了MySQL,在登录时用如下命令:

   mysql -u user_1 -p -h 192.168.113.50 (-h后跟的是要登录主机的ip地址)

   十、备份与恢复

   1、备份

   例如:将上例创建的aaa库备份到文件back_aaa中

   [root@test1 root]# cd /home/data/mysql (进入到库目录,本例库已由val/lib/mysql转到/home/data/mysql,见上述第七部分内容)

   [root@test1 mysql]# mysqldump -u root -p –opt aaa > back_aaa

   2、恢复

   [root@test mysql]# mysql -u root -p ccc < back_aaa


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=150

发表一篇回复 » 文章所属分类为 数据库 by LanCao at 15:59.

回到页头

Monday, 1 de June de 2009

Webalizer

webalizer是一个高效的、免费的web服务器日志分析程序。其分析结果以HTML文件格式保存,从而可以很方便的通过web服务器进行浏览。Internet上的很多站点都使用webalizer进行web服务器日志分析。Webalizer具有以下一些特性:  1. 为是用C写的程序,所以其具有很高的运行效率。在主频为200Mhz的机器上,webalizer每秒钟可以分析10000条记录,所以分析一个40M大小的日志文件只需要15秒。  2. webalizer支持标准的一般日志文件格式(Common Logfile Format);除此之外,也支持几种组合日志格式(Combined Logfile Format)的变种,从而可以统计客户情况以及客户操作系统类型。并且现在webalizer已经可以支持wu-ftpd xferlog日志格式以及squid日志文件格式了。  3. 支持命令行配置以及配置文件。  4. 可以支持多种语言,也可以自己进行本地化工作。  5. 支持多种平台,比如UNIX、linux、NT, OS/2 和 MacOS等。  安装:  1.从webalizer的官方站点http://www.mrunix.net/webalizer/下载webalizer,当前的最新版本是webalizer-2.01-06-src.tgz。  2.首先解开源代码包:  tar xvzf webalizer-2.01-06-src.tgz  3.在生成的目录中有个lang目录,该目录中保存了各种语言文件,但是只有繁体中文版本,可以自己转换成简体,或者自己重新翻译一下。  4.然后进入生成的目录:  ./configure  make –with-language=chinese  5.编译成功后,会产生一个webalizer可执行文件,可以将其拷贝到/usr/sbin/目录下:  cp webalizer /usr/sbin/  然后就可以开始配置webalizer了。  配置:  上面说过,可以通过命令行配置webalizer,也可以通过配置文件进行配置,在本文中我们将介绍使用命令行参数进行配置,需要了解配置文件使用方法的朋友可以参考README文件,里面有很详细的介绍。  可以执行webalizer –h得到所有命令行参数:  Usage: webalizer [options] [log file]  -h = 打印帮助信息  -v -V = 打印版本信息  -d = 打印附加调试信息  -F type = 日志格式类型. type= (clf | ftp | squid)  -i = 忽略历史文件  -p = 保留状态 (递增模式)  -q = 忽略消息信息  -Q = 忽略所有信息  -Y = 忽略国家图形  -G = 忽略小时统计图形  -H = 忽略小时统计信息  -L = 忽略彩色图例  -l num = 在图形中使用数字背景线  -m num = 访问超时 (seconds)  -T = 打印时间信息  -c file = 指定配置文件  -n name = 使用的主机名  -o dir = 结果输出目录  -t name = 指定报告题目上的主机名  -a name = 隐藏用户代理名称  -r name = 隐藏访问链接  -s name = 隐藏客户  -u name = 隐藏URL  -x name = 使用文件扩展名  -P name = 页面类型扩展名  -I name = index别名  -A num = 显示前几名客户类型  -C num = 显示前几名国家  -R num = 显示前几名链接  -S num = 显示前几名客户  -U num = 显示前几名URLs  -e num = 显示前几名访问页面  -E num = 显示前几名不存在的页面  -X = 隐藏个别用户  -D name = 使用dns缓存文件  -N num = DNS 进程数 (0=禁用dns)  假设,web服务器主机名为www.test.com,统计站点域名为www.test.com, 访问日志为/var/log/httpd/access_log, 我们将webalizer分析结果输出到/var/www/html/log下面。则我们可以建立以下脚本/etc/rc.d/webalizer:  #!/bin/sh  run=/usr/sbin/webalizer  $run -F clf -p -n ” ” -t “www.test.com”  -o /var/www/html/log /var/log/httpd/access_log  说明:  -F clf 指明我们的web日志格式为标准的一般日志文件格式(Common Logfile Format)  -p 指定使用递增模式,这就是说每作一次分析后,webalizer会生产一个历史文件,这样下一次分析时就可以不分析已经处理过的部分。这样我们就可以在短时间内转换我们的日志文件,而不用担心访问量太大时日志文件无限增大了。  -n “ “ 指定服务器主机名为空,这样输出结果会美观一些。  -o “www.test.com” 指定输出结果标题.  /var/log/httpd/access_log:指定日志文件  然后在/etc/crontab中加入:  01 1 * * * root /etc/rc.d/webalizer  即每天凌晨1点执行该脚本。  然后运行/etc/rc.d/init.d/crond reload重载入crond服务。  测试:  执行以下命令:  # /etc/rc.d/webalizer  然后在浏览器中访问http://www.test.com/log/就可以看到webalizer的分析结果了。  注意:如果您使用了中文语言文件,但是您的linux不支持中文,则在产生的图片中文字可能为乱码。  


转载原创文章请注明,转载自:web蓝草博客–LanCao’s Web Blog[http://www.juuyou.com]

本文链接: http://www.juuyou.com/?p=148

发表一篇回复 » 文章所属分类为 其他 by LanCao at 16:10.

回到页头


版权声明

Copyright © web蓝草博客–LanCao’s Web Blog | Powered by WP 2.2.1. | Tree by Headsetoptions and MandarinMusing a minimal theme based on HyperBallad
Back to Content
沪ICP备07022431号

˽ ˽ 漣˽ ˽