Issue
- How can we install an apache web server and connect the same with the application server over a Linux-based operating system?
Environment
- Liferay DXP 7.4
Resolution
-
The following are the steps that will help you set up the Apache web server and connect it to Tomcat-based Liferay using mod_jk:
1. Prerequisites: Tomcat bundled Liferay and Sudoer user to install and configure HTTPD.
2. Install httpd using the command:sudo yum install httpd
.
3. Install Associated packages usingsudo yum install httpd-devel apr apr-devel apr-util apr-util-devel gcc gcc-c++ make autoconf libtool
4. Verify the installation: Go to /etc/httpd/ and check the list of files there.
5. Run thesudo systemctl start httpd.service
command to start the Apache server and test on the browser for the default landing page.
6. Install mod_jk: Follow the below commands to make and install mod_jk connector from the source:
1. sudo wget https://archive.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.49-src.tar.gz
2. sudo tar -xvzf tomcat-connectors-1.2.49-src.tar.gz
3. cd tomcat-connectors-1.2.49-src/native
4. sudo ./configure --with-apxs=/usr/bin/apxs
5. sudo dnf install redhat-rpm-config
6. sudo make
7. sudo libtool --finish /usr/lib64/httpd/modules
8. sudo make install
9. ls /usr/lib64/httpd/modules
10. ls -l /etc/httpd/modules/mod_jk.so
11. sudo mkdir -p /var/run/mod_jk
12. sudo chown apache:apache /var/run/mod_jk
7. Verify if the filemod_jk.so
is present at/etc/httpd/modules
8. Configure AJP in Tomcat: Uncomment the ajp connector fromliferay_home/tomcat-9.0.xx/conf/server.xml
and edit like below.
Note: Change the IP address to the IP of the Liferay server/Application Server and enter a strong secret in<Connector protocol="AJP/1.3"
address="IP of the Liferay Server/Application Server"
port="8009"
redirectPort="8443" URIEncoding="UTF-8" secret="Enter a strong secret" />secret
.
9. Configure mod_jk: Create and add the below configuration to/etc/httpd/conf/workAers.properties
:
Note: Add the same secret that was added in ajp connector of Liferay.worker.list=loadbalancer
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=node1
worker.loadbalancer.secret= Add the secret
worker.node1.host=192.168.122.4
worker.node1.port=8009
worker.node1.type=ajp13
worker.node1.lbfactor=1
10. Configure/etc/httpd/conf.d/mod_jk.conf
like below:
LoadModule jk_module "/etc/httpd/modules/mod_jk.so"
JkWorkersFile /etc/httpd/conf/workers.properties #Path to workers.properties file created above
JkShmFile /var/run/httpd/mod_jk.shm #Where to put jk shared memory
JkLogFile /var/log/httpd/mod_jk.log #Where to put jk logs JkLogFile
JkLogLevel info #Set the jk log level [debug/error/info]
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " #Select the timestamp log format
11. Add jkmount inside your virtual host configuration -
JkMount /* loadbalancer
JkMount / loadbalancerAdd the above to the file
httpd.conf
if SSL is not required and tossl.conf
if SSL is enabled.
Additional Information
- How to find your IP address in Linux
- Please note that the installation and configuration of a WebServer on a machine comes under a third-party application and Liferay support will be limited in this case.