Webalizer installation and configuration (solve Chinese image garbled characters)
Baidu business card:
Webalizer is an efficient and free web server log analysis program. The analysis results are saved as HTML files, which can be easily viewed on the web server. Many websites on the Internet use webalizer for web server log analysis.
Build the environment and required software packages:
System: centos 5.5
Jpeg Library
Zlib library
Libpng library
Freetype font library
Gd library
Http service (rpm package)
GeoIP-1.4.8.tar.gzGeoIP library, used to resolve the country list corresponding to the IP address
Webalizer-2.23-05-src.tgzwebalizer MAIN package
I. Build an environment
Related jpeg, png, and zlib libraries are required for Webalizer. Some of these libraries are installed by default, and some must be manually installed. The installation steps cannot be reversed and must be installed in sequence.
You can download the source code package for installation. The steps are generally:
#./Configure
# Make
# Make install
Here I use the yum package to install it. This can easily solve the dependency package problem and is suitable for beginners.
1. First, attach the disc and remember the path to attach the disc.
# Mount/dev/cdrom/mnt/cdrom/here I mount it to the/mnt/cdrom directory
2. Modify the yum configuration file
# Vi/etc/yum. repos. d/CentOS-Media.repo configuration file storage path
C5-media
Name = CentOS-$ releasever-Media
Baseurl = file: // media/CentOS/
File: // mnt/cdrom/change the file to the CD path.
File: // media/cdrecorder/
Gpgcheck = 1
Enabled = 0
Gpgkey = file: // etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Save and exit. Run the # yum list command to view the yum package. If yum is created successfully, the list is displayed.
3. Install the required libraries.
First install the first jpeg library,
# Yum install jpeg * install the jpeg library command, which will be automatically installed by the System
All libraries are installed in the same way. You can install them one by one.
4. Install the httpd service
Here we can also use the yum package for installation.
# Yum install httpd *
Ii. Install webalizer
1) install the GeoIP library, which can be used to analyze ip addresses in different countries.
# Tar-zxmf GeoIP-1.4.8.tar.gz extract source package
# Cd GeoIP-1.4.8 to enter the extract directory
#./Configure for pre-compilation Configuration
# Make Compilation
# Make install Installation
After the installation is complete, a GeoIP. dat file is generated under/usr/local/share/GeoIP /.
2) Compile Chinese fonts and support Chinese output
# Tar-zxmf webalizer-2.23-05-src.tgz unzip webalizer
# Cd webalizer-2.23-05 to enter the extract directory
# Enter the language directory for cd lang
Find webalizer_lang.simplified_chinese to convert the file format to UTF-8. You can use an external tool to modify the file and put it back. Here I use EditPlus 3 for format conversion. You can download some software online to convert the file format. If you do not need to convert the file format, this step can be skipped.
# Cd .. back to the parent directory
Find a chinese font and upload it to the server, such as/usr/share/fonts/chinese/TrueType/ukai. ttf, provided that the gd package has been installed on the server and freetype is successfully supported. You can see if the gd package is supported when you install it. the cent OS I use directly supports Chinese characters, so the system's built-in simhei
Font search method: find/-name *. ttf search
# Vi graphs. c Open graphs. c and add the following code. I will add the last line.
Void gdImageString (gdImagePtr im, gdFontPtr font, int x, int y, unsigned char * s, int color)
{
GdImageStringFT (im, 0, color, "/usr/share/fonts/chinese/TrueType/ukai. ttf ", 9, 0.0, x, y + 9, s); // note that the font path is changed here.
}
Void gdImageStringUp (gdImagePtr im, gdFontPtr font, int x, int y, unsigned char * s, int color)
{
GdImageStringFT (im, 0, color, "/usr/share/fonts/chinese/TrueType/ukai. ttf", 9,-PI/2, x, Y-9, s );
} // Note that the font path is changed here.
In this way, the localization process ends, and we start to formally install webalizer.
3) install webalizer
#./Configure -- prefix =/usr/local/webalizer \ installation directory
> -- Enable-geoip \ enable geoip support
> -- With-geoip =/usr/local/include \ geoip path
> -- With-geoiplib =/usr/local/lib \ geoiplib LIBRARY PATH
> -- With-language = simplified_chinese supports Simplified Chinese
# Make compilation here, if your system clock is incorrect, a warning will be issued. If a clock error is detected, we can modify the clock and continue.
Modification time method:
# Date 080410382011.10 sequence: month, day, hour, year, second
Then proceed
# Make install Installation
# Cp sample. conf/etc/webalizer. conf copy the strength file of the source code package and put it under/etc. If you do not perform this operation, the system automatically calls the default master configuration file.
4)
3. Configure webalizer
1) Import logs to the system. Here I will pull some log files from the server and put them under/opt /.
2) modify the master configuration file
# Vi/etc/webalizer. conf
LogFile/opt/access.tar.gz specifies the location of the log file, which can be a compressed package
LogType clf set Log Type
OutputDir/var/www/html/test
HostName test
GeoIPyes enables the geoip Function
GeoIPDatabase/usr/local/share/GeoIP. dat point to geoipdatabase path
Save and exit
3) create a directory for generating data records
# Mkdir-p/var/www/html/test
4) Copy libGeoIP to/usr/lib. Otherwise, an error will be reported when the service is started.
# Cp-d-p/usr/local/lib/libGeoIP */usr/lib/
4. Start and test the service
1) create a script
# Vi test. sh
#! /Bin/sh
Run =/usr/local/webalizer/bin/webalizer
$ Run-F clf-p-n ''-C'/etc/webalizer. conf' parameters are described at the end of this article.
2) start the service
[Root @ Rytong/] #./test. sh
Webalizer V2.23-05 (Linux 2.6.18-92. el5 i686) Simplified Chinese
Use the log file/opt/access.tar.gz (gzip-clf)
Using GeoIP Country Edition (/usr/local/share/GeoIP. dat)
Output the result to/var/www/html/test.
The report generation host name is 'test'
No history file found...
The last running data not found...
Warning truncation of too long hostname Fields
Skipping error records (1)
Saving the currently running data... [16:29:39]
Generating report ---- July 20
Saving the history file...
Generating comprehensive report
9185 records (7 ignored records, 1 invalid records) in total: 1 second, 9185/sec
Enable the httpd service and access the statistics page in the browser
Http: // 192.168.20.167/test
3) Access results:
Visit the home page.
View monthly statistics
View country statistics.
5. control monitoring through commands
The above is configured through a file, or webalizer can be configured through the command line. For details about how to use the configuration file, refer to the README file. You can run webalizer-h to obtain all command line parameters:
Usage: webalizer [options] [log file]
-H = print help information
-V-V = print version information
-D = print additional debugging information
-F type = log format type. type = (clf | ftp | squid)
-I = ignore historical files
-P = retention (incremental Mode)
-Q = ignore message information
-Q = ignore all information
-Y = ignore country graphics
-G = ignore hour statistics
-H = ignore hour statistics
-L = ignore color legend
-L num = use a digital background line in the image
-M num = access timeout (seconds)
-T = print time information
-C file = Specify the configuration file
-N name = used Host name
-O dir = result output directory
-T name = Specify the host name on the report question
-A name = hide the user agent name
-R name = hide access Link
-S name = hiding customers
-U name = hide URL
-X name = use the File Extension
-P name = page Type Extension
-I name = index alias
-A num = display the first customer types
-C num = display the first countries
-R num = display the first few links
-S num = display previous customers
-U num = display the first few URLs
-E num = display the first few access pages
-E num = display the first few non-existing pages
-X = hide individual users
-D name = use dns to cache files
-N num = number of DNS processes (0 = disable dns)
The software package required in this article is a great tool. If you cannot find it online, you can add QQ
QQ: 3619352
If there are any omissions or errors in this article, I hope you can point out that I will correct them.