普通方式安装 httpd 服务器。
[root@openbravo ~]# dnf install httpd
[root@openbravo ~]# systemctl start httpd
[root@openbravo ~]# systemctl enable httpd
源代码安装配置mod_jk
[root@openbravo ~]# wget https://www-us.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.46-src.tar.gz
[root@openbravo ~]# tar -zxvf tomcat-connectors-1.2.46-src.tar.gz
[root@openbravo ~]# cd tomcat-connectors-1.2.46-src/native/
[root@openbravo native]# ./configure --with-apxs=/usr/bin/apxs
[root@openbravo native]# libtool --finish /usr/lib64/httpd/modules
libtool: finish: PATH="/opt/ant/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib/jvm/java-11-openjdk-11.0.5.10-0.el8_0.x86_64/bin:/root/bin:/sbin" ldconfig -n /usr/lib64/httpd/modules
----------------------------------------------------------------------
Libraries have been installed in:
/usr/lib64/httpd/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
[root@openbravo native]# make install
检查mod_jk是否正常安装
[root@openbravo native]# ls /usr/lib64/httpd/modules/
[root@openbravo native]# vim /etc/httpd/conf.d/jk.conf
[root@openbravo native]# cat /etc/httpd/conf.d/jk.conf
LoadModule jk_module /etc/httpd/modules/mod_jk.so
JkWorkersFile /etc/httpd/conf.d/workers.properties
JkShmFile /var/log/httpd/mod_jk.shm
JkLogFile /var/log/httpd/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
[root@openbravo native]# touch /var/log/httpd/mod_jk.shm /var/log/httpd/mod_jk.log
[root@openbravo conf.d]# vim workers.properties
[root@openbravo conf.d]# cat workers.properties
#Define the list of workers you have
worker.list=jkstatus,lb_router
# Set LOADBALANCER
worker.lb_router.type=lb
worker.jkstatus.type=status
# HERE is where you decide on how many Tomcat Server's there are in the cluster
#worker.lb_router.balance_workers=tc-node1,tc-node2
worker.lb_router.balance_workers=ajp13_worker
worker.lb_router.sticky_session=1
# Set Worker
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=openbravo.contoso.com
worker.ajp13_worker.type=ajp13
worker.ajp13_worker.lbfactor=1
#worker.tc-node2.port=8009
#worker.tc-node2.host=tc_node1.contoso.com
#worker.tc-node2.type=ajp13
#worker.tc-node2.lbfactor=1
[root@openbravo conf.d]# vim openbravo.conf
[root@openbravo conf.d]# cat openbravo.conf
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/json
</IfModule>
jkMount /openbravo* ajp13_worker
JkMountCopy all
[root@openbravo conf.d]#
配置selinux 放行httpd服务
[root@openbravo ~]# systemctl restart httpd
[root@openbravo ~]# journalctl -xe
[root@openbravo ~]# ausearch -c 'httpd' --raw | audit2allow -M my-httpd
[root@openbravo ~]# semodule -X 300 -i my-httpd.pp
[root@openbravo ~]# setsebool -P domain_can_mmap_files 1
[root@openbravo ~]# systemctl restart httpd
[root@openbravo ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2019-11-21 08:47:47 EST; 9s ago
Docs: man:httpd.service(8)
Main PID: 7994 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 4595)
Memory: 24.9M
CGroup: /system.slice/httpd.service
├─7994 /usr/sbin/httpd -DFOREGROUND
├─7995 /usr/sbin/httpd -DFOREGROUND
├─7996 /usr/sbin/httpd -DFOREGROUND
├─7997 /usr/sbin/httpd -DFOREGROUND
└─7998 /usr/sbin/httpd -DFOREGROUND