apache, tomcat have been installed, and each can provide services normally. The static resources of apache can be accessed normally through port 80, and the resources of tomcat can be accessed through port 8080. So how to access tomcat resources through apache, that is, how to connect Apache and Tomcat. That's what mod_jk needs to do.
Check whether Mod_jk can work normally by configuring the status worker of mod_jk
Status worker is a built-in management worker. It displays the status information of mod_jk, including some configuration information and url mapping information of other workers (AJP workers).
Let’s not talk about the conceptual content first, let’s turn it around first. . .
Installation of mod_jk
1. Install the rpm package
rpm -ivh mod_jk-1.2.41-httpd_2.4.6_40.el7_2.1.x86_64.rpm
2. Confirm
rpm -qa |grep "mod_jk"
ls -l /etc/httpd/modules/mod_jk.so
3. Confirm that mod_jk can work normally by visiting jkstatus
There are mainly two configuration files involved here
1)/etc/httpd/conf.d/mod_jk.conf
JkMount / jkstatus jkstatus
Analysis: /jkstatus mount point, jkstatus, work.list defined in work.properties
2)/etc/httpd/conf/work.properties
work.list=jkstatus
work.jkstatus.type=status
4. Restart the httpd service
systemctl restart httpd
Of course, the final item is /etc/httpd/conf/httpd. conf must read the files of /etc/httpd/conf.d/* , so that mod_jk.conf will be loaded.
IncludeOptional conf.d/*.conf
5. Try to visit the following URL
http://192.168.100.29/jkstatus
The screen is displayed normally, but the actual dredging process is not so simple. After checking a lot of information, I seem to understand how to match this.
6. Configure the access rights of jkstatus
At the end of mod_jk.conf, add the following configuration and restart the httpd service. It seems simple and actually encountered some problems (problem summary section).
<Location /jkstatus>
AuthType Basic
AuthName "Status worker"
AuthUserFile /etc/httpd/conf/jkstatus.file
<RequireAll>
Require user jkstatus
Require ip 10.0.210.135
</RequireAll>
</Location>
But when you finally visit http://192.168.100.29/jkstatus , a dialog box will pop up, you need to enter the user name and password, after entering jkstatus, 123456, the jkstatus screen can be displayed normally.
To sum up, at this point, it can be said that mod_jk can also be turned normally. . .
summary of a problem
1. After completing step 6, I visited the URL, and a box popped up to enter the user name and password. After it was closed, it kept reporting an error, so I went to the log again and said it was /etc/httpd/conf/jkstatus.file. The file cannot be opened or does not exist. So I went to the Internet to find information, and finally generated the username and password file through the following command
htpasswd -cmb /etc/httpd/conf/jkstatus.file jkstatus 123456
htpasswd is a tool of apache. It will exist after apache is installed. This tool is mainly used to create and update text files that store user names and passwords, and is mainly used to authenticate HTTP-based users. The above command means to generate a jkstatus.file password file in the /etc/httpd/conf/ directory, and add a new user whose username is jkstatus and whose password is 123456, which is encrypted by MD5 encryption by default.
For details about this command, please refer to the link below, which I think is written in great detail.
http://www.jb51.net/article/59468.htm
2. In apache's access.log, I often see that /favicon.ico cannot be found (404), but if you create an empty file with this name under /var/www/html, the error will disappear. . . What the hell is this doing, I'll add it after I learn
0.0.210.135 - - [01/Aug/2017:09:14:32 +0900] "GET /favicon.ico HTTP/1.1" 404 209 "http://192.168.100.29/jkstatus" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"