Installing a log file analyzer on your server is probably one of the most useful projects you can undertake other than security.
DOWNLOAD AWstats
You can download the latest version of AWstats from http://awstats.sourceforge.net/#DOWNLOAD
INSTALL AWstats
You can install AWstats in almost any directory. I suggest you install it in
E:\usr\local\awstats\
AWstats and PERL were written to run in a UNIX enviroment therefore the installation and the documentation refer to LINUX configuration settings.
I suggest you choose the zip version so that you can configure it as you wish. Either the zip or the windows exe version are fine as long as the following are true:
find
E:\usr\local\awstats\wwwroot\cgi-bin\awstats.pl
and confirm that the very first line reads
#!/usr/bin/perl
DOWNLOAD PERL
Download the latest version of ActivePerl from http://www.activestate.com/store/activeperl/download (if it asks you to register, you can just leave the form blank and hit “Continue”). Get the Windows (x86) MSI version. My file was named: ActivePerl-5.8.8.820-MSWin32-x86-274739.msi
INSTALL PERL
On the “Setup” screen (where you choose what features to install — should be about the 2nd or 3rd screen in. I tend to miss it every time and have to go back) change the install location (hit the little “browse” button). I highly recommend that you install perl to a directory like: E:\usr\ on a windows platform.
| Suggested install location |
| If you will be using Perl CGI programs and want to maintain some level of portability between both Linux machines and Windows machines, you will want to install Perl to the same location on your Windows machine that it is on most Linux machines. For example, on a standard Linux machine, Perl is located at /usr/bin/perl and so almost every Perl program that is written begins with #!/usr/bin/perl. So, when you install Perl on a Windows machine, instead of installing it in the default location (which is E:\perl for ActivePerl) You should install it in E:\usr so that the Perl executable is located at /usr/bin/perl. This allows you to write code on a Windows machine, then move it (without making any changes) to a Linux machine and have it run there. And vice versa. |
[Check] Add Perl to the PATH environment variable
Start->right click on MyComputer -> Properties -> Advanced Tab -> Enviroment Variable on the very bottom in the Systems Variable list find the Path variable and
click edit and add ( E:\usr\site\bin;E:\usr\bin; ) { it is suggested that you install your server on a different drive than your operating system for security purposes such as operating system on C: and server on E: } but you can use the C: drive.
[Check] Create Perl file extension association The rest should be grayed out and read-only, but if not, leave them unchecked
Activating CGI
Using Notepad (or other text editor) open E:\Apache2_2\conf\httpd.conf (also should be start-menu shortcut called “Edit Apache HTTP httpd.conf File”) and search for Options Indexes FollowSymLinks (about line 267) when you find it add ExecCGI to the end so it looks like:
Options Indexes FollowSymLinks ExecCGI
[OPTIONAL] Enabling CGI in any directory
If you want to use CGI outside the E:/Apache2_2/cgi-bin/ ScriptAliased directory, you will need to uncomment the following line: #AddHandler cgi-script .cgi becomes AddHandler cgi-script .cgi (remove the #) I also added .pl behind .cgi so ‘perl’ extension is also treated as cgi files. If you will be creating your own cgi-bin, you will want to comment out: ScriptAlias /cgi-bin/ “E:/Apache2/cgi-bin/” so it becomes #ScriptAlias /cgi-bin/ “E:/Apache2/cgi-bin/”
Enabling SSI [optional]
Find the line from Step 1: Activating CGI and add Includes to the end so it becomes Options Indexes FollowSymLinks ExecCGI Includes Find and uncomment the following lines #AddType text/html .shtml and #AddOutputFilter INCLUDES .shtml (Search for them, then remove the #)
| Some notes |
| If you don’t know what SSI (Server Side Include) is, I suggest looking for more info about it. It is a huge time saver for updating pages (you can update one “menu file” and have hundreds of pages reflect the updated changes). However, it adds additional strain on a server and can potentially make a server slightly less secure, so if you are not using, do not enable it. Since I use SSI for everything, I changed the settings so *.html files can also run SSI (by default it’s only .shtml). So I have AddOutputFilter INCLUDES .shtml .html AddOutputFilter is completely different than the AddHandler server-parsed way Apache 1.3.x handled it. |
FINDING YOUR PERL LOCATION or SETTING IT
If you do not know where your perl.exe installed to, go to Start -> Search and type in a search for perl.exe This location is the path to perl you put on the top of all your cgi scripts. If you listened to my advice in the “Install” step, the path should be close to: E:/usr/bin/perl.exe
| Some notes |
| For the perl path E:/usr/bin/perl.exe all of these are/were valid. I prefer the last one because of the Linux <<>> Windows portability. #!E:/usr/bin/perl.exe #!E:/usr/bin/perl #!/usr/bin/perl.exe #!/usr/bin/perl |
CONFIGURING APACHE 2 to run AWstats and PERL
When updating your Apache Server its a good idea to make changes in steps and restart your server to confirm that there are no errors.
Right after the Listen command and
insert LoadFile “C:/usr/bin/perl58.dll”
just before the LoadModule directives
Uncomment { remove the # } LoadModule perl_module modules/mod_perl.so
The following is optional but you can add the following in between the
<IfModule alias_module>
add ScriptAlias /cgi “E:/usr/bin”
</IfModule>
Find
###
# “E:/Apache2/cgi-bin” should be changed to whatever your ScriptAliased
# CGI directory is set to above ^ such as ScriptAlias /cgi “E:/usr/bin” ###
and Add the following
<Directory “E:/usr/bin”>
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
Find the
<IfModule mime_module>
and ADD or EDIT the following directive by adding .pl
AddHandler cgi-script .cgi .pl
<IfModule>
THATS IT!
If you want to limit the use of your cgi or perl scripts to your local network add the following:
<Directory “E:/usr”>
Options ExecCGI -Indexes FollowSymLinks
Order Deny,Allow
Deny from all
Allow from 127.0.0
Allow from 192.168.1
</Directory>
Save the following script as test.pl in your document folder and access it in your browser to check functionality:
or use
#!/usr/bin/perl.exe
# ^^^ the above line must be the first line of the script! ^^^
# start code
use strict;
use CGI;
my $q = new CGI;
# print header and start the markup output
print $q->header( “text/html” ),$q->start_html( “Hello from SEOPerfectCart” );
print $q->h2( ‘SEOPerfectCart download at <a href=”http://www.obazaar.com/”>Obazaar</a>’ );
print $q->end_html;
# end code
When you copy the script delete any spaces before the first line f the exist.
Testing CGI
If you if you uncommented (removed the # symbol) the line AddHandler cgi-script .cgi in Apaches httpd.conf , then create a file in your document_root called hello.cgi and put these three lines in it (if you did not comment/disable it, put the CGI file in E:/Apache2_2/cgi-bin/):
“Content-type:text/htmlnn”;
print “hello world”;
Restart Apache if it is already running. Now go to http://localhost/cgi-bin/hello.cgi (or wherever you put the file) and run the script.
If you get a hello world in your browser, CGI is running. If you get a 500 error, go to the last entry in E:/Apache2_2/logs/error.log (or the Review Error Log in the start menu) to see exactly what caused this error.
RUNNING AWstats
http://www.yourdomain.com/awstats/awstats.pl
The folloeing page will appear if you didnt set up AWstats correctly
Error: Couldn’t open config file “awstats.www.seoperfectcart.com.conf” nor “awstats.conf” after searching in path “C:/WWW/AWStats/wwwroot/cgi-bin,/etc/awstats,/usr/local/etc/awstats,/etc,/etc/opt/awstats”: No such file or directory
- Did you use the correct URL ?
Example: http://localhost/awstats/awstats.pl?config=mysite
Example: http://127.0.0.1/cgi-bin/awstats.pl?config=mysite
- Did you create your config file ‘awstats.www.seoperfectcart.com.conf’ ?
If not, you can run “awstats_configure.pl” from command line, or create it manually.
Check config file, permissions and AWStats documentation (in ‘docs’ directory).
If the above page appears and AWstats is configured correctly type the following:
http://www.yourdomain.com/awstats/awstats.pl?config=yourdomain
Dont forget to click update now next to the date.
TROUBLESHOOTING
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, email@domain.net and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log.
If you receive the above error check the first line of C:\AWStats\wwwroot\cgi-bin\awstats.pl or wherever you installed AWstats it should read…
if you have PERL installed in the C:\usr\bin\perl or E:\usr\bin\perl directory which is suggested becuase many PERL programs are written for LINUX systems.
otherwise AWstats will not run.




