summaryrefslogtreecommitdiffstats
path: root/INSTALL
diff options
context:
space:
mode:
Diffstat (limited to 'INSTALL')
-rw-r--r--INSTALL180
1 files changed, 180 insertions, 0 deletions
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..0229879
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,180 @@
1$Id: INSTALL,v 1.1 2001/11/28 05:26:54 helios Exp $
2
3
4Requirements
5============
6
70) I run a Red Hat 6.2 system, but these instructions should easily
8 adapt to any modern distro.
9
101) Apache 1.2.x or higher installed. (I run 1.3.22 and it works fine).
11 You should have already successfully compiled Apache and know what
12 you're doing there. In fact, you should already have any other
13 modules and add-ons like mod_ssl or PHP configured and installed
14 before you start this process.
15
162) The MySQL development headers. (I run MySQL-devel-3.23.44-1.i386.rpm).
17
183) MySQL configured, installed and running on either localhost or an
19 accessible networked machine. You should already have a basic
20 understanding of MySQL and how it functions.
21
224) Again, basic administrative skills with Apache and MySQL. I try to
23 make things as easy as possible in this README, but its purpose is
24 not to be an administrative tutorial.
25
26Installation
27============
28
290) Perform all the following steps as root so that you have install
30 privs, etc.
31
321) Unpack the archive into a working directory.
33
34 # tar zxf mod_log_mysql.tar.gz -C /usr/local/src
35 # cd /usr/local/src/mod_log_mysql
36
372) Edit Makefile and make any adjustments for your system: make sure
38 that APACHEDIR points to the location of your Apache source code,
39 and that CFLAGS points to the location of your Apache installation
40 directory (where your httpd binary lives).
41
423) # make all
43 (You should receive NO warnings or errors of any kind.
44 If you see messages like this: "mod_log_mysql.c:69: httpd.h: No such
45 file or directory" then you do not have your CFLAGS correctly
46 pointing to the right include directory.)
47
484) # make install
49
505) Change to your Apache source dir.
51
52 # cd /usr/local/src/apache-1.3.22/src
53
546) Re-make your httpd binary as follows.
55
56 6a) Edit Configuration.apaci as follows...
57
58 * Append the following string to the EXTRA_LIBS= line. (/usr/lib/mysql is where your libmysqlclient.a file lives):
59 -L/usr/lib/mysql -lmysqlclient -lm
60
61 * Add this line at the end of the file:
62 Module mysql_log_module mod_log_mysql.o
63
64 6b) # cp Configuration.apaci Configuration
65
66 6c) # ./Configure
67
68 6d) # make
69
70 6e) # strip httpd
71
727) Test your new apache binary:
73
74 # ./httpd -l
75
76 You should see something like:
77
78 Compiled-in modules:
79 http_core.c
80 mod_log_mysql.c <-- That's the line you're looking for.
81 mod_env.c
82 mod_log_config.c
83 mod_mime.c
84 mod_negotiation.c
85 ...etc...
86
878) Install your httpd binary. Copy it over your old httpd binary,
88 wherever it lives. You can and should rename your old httpd first so
89 that you can easily revert to that working version in case of bugs or
90 whatever.
91
92 # /etc/rc.d/init.d/httpd stop
93 # cp -f ./httpd /usr/local/Apache/bin/
94
959) Configure your apache daemon to log to your database. Here's a very
96 basic set of config lines to start you off. Full docs on them are
97 included after this section.
98
99 EXAMPLE: Connect to the MySQL database called "apache" running
100 on "dbmachine.foo.com". The module uses username "loguser" and
101 password "l0gger" to authenticate to the database; this user must,
102 of course, exist in the MySQL user table and have the proper
103 permissions -- more on that in step 11. The log entries will be
104 INSERTed into the table called "access_log".
105
106
107 LogMySQLInfo dbmachine.foo.com loguser l0gger
108 LogMySQLDB apache
109
110 <VirtualHost 1.2.3.4>
111 [snip]
112
113 TransferLogMySQLTable access_log
114 TransferLogMySQLFormat huSUsbTvRA
115
116 [snip]
117 </VirtualHost>
118
119
12010) Create a database and table to hold the new log data. I log the
121 same data as the regular "combined log" plus a little extra information
122 that can be useful.
123
124 The order that the fields appear in the table is irrelevant
125 because you can SELECT them in any order you choose. To create
126 this table I first created a new database called "apache":
127
128 # mysql -uadmin -pmypassword
129 mysql> create database apache;
130
131 Then I created the table called "access_log". You should use the
132 enclosed SQL file to do this for you.
133
134 mysql> source access_log.sql
135
136
13711) Create a specific mysql userid that httpd will use to authenticate
138 and enter data. This userid need not be an actual Unix user. It
139 is a userid specific to mysql with specific privileges. To create a
140 user called "loguser" with the password "l0gger" with only the
141 capability of INSERT to "access_log":
142
143 mysql> grant insert on apache.access_log to loguser@my.apachemachine.com identified by 'l0gger';
144
145
14612) Enable full logging of your MySQL daemon (at least temporarily
147 for debugging purposes) if you don't do this already:
148
149 Edit /etc/my.cnf and add the following line to your [mysqld] section:
150
151 log=/var/log/mysql-messages
152
153 Then restart MySQL.
154
15513) Restart apache.
156
157 # /etc/rc.d/init.d/httpd start
158
15913) Load your web site in a browser to trigger some hits, then confirm that
160 the entries are being successfully logged:
161
162 # mysql -hmysql.host.com -umysqladmin -p -e "select * from access_log" apache;
163 Enter password:
164
165 +---------------------------------------------------+-------------+-------------+------------------+------------------+------------+--------+------------+------------------------------------+
166 | remote_host | remote_user | request_uri | request_duration | virtual_host | time_stamp | status | bytes_sent | referer |
167 +---------------------------------------------------+-------------+-------------+------------------+------------------+------------+--------+------------+------------------------------------+
168 [snipped lines]
169 .
170 .
171 .
172 +---------------------------------------------------+-------------+-------------+------------------+------------------+------------+--------+------------+------------------------------------+
173
17414) You have basic functionality. Don't disable your regular Apache logs until
175 you feel comfortable that the database is behaving as you'd like and that
176 things are going well.
177
178
179
180