Problem :
How to start two Liferay servers at the same time with different ports ?
Sometimes we need to start multiple Liferay servers into one system in order to locally debug the problems with the clustering or remote staging features.
Solution :
We can modify the Liferay Tomcat server configuration and change the Elasticsearch properties using Liferay OOTB.
Environment Requirements :
- Liferay Portal
Here I am starting two Liferay servers simultaneously.
I am choosing the following version, You can choose as per your requirements.
- Liferay-dxp-7.4.13.u50
- Liferay-dxp-7.4.13.u60
First Liferay Server
Please follow below steps to start the first liferay
- Start liferay-dxp-7.4.13.u50 → tomcat-9.0.65 → bin → startup (for Windows: batch file, and for Linux: shell script file)
- After the successful startup of liferay, Sign in to the site as an Admin.
- Sign in successfully with localhost:8080
- Next, open the Global Menu (◧) .Then navigate to Control Panel → Configuration → System Settings.
- Click on System Settings → Platform section → click on the Search.
- Click on Search, open a new tab, and look like the below image:
- Click on Elasticsearch 7 and replace the existing embedded HTTP port – 9201 with the new embedded HTTP port – 9301 and then click on the Save button.
- Restart the Liferay. Check Liferay starts with new Elasticsearch at the new port.
- In the portal-setup-wizard.properties file, add the following line:
module.framework.properties.osgi.console=11312
(Port changed here from default 11311 to 11312).
Second Liferay Server
Follow the below steps.
- First you have to modify the liferay tomcat server configuration.
It’s required to change http connector port, Server port, Redirect ports and AJP connector port in tomcat server.xml file - Open liferay → tomcat-9.0.65 → conf → server.xml
- Open the server.xml file and update the following ports.
- Server port
Here, the server port is 8005.
Now you have to change this port from 8005 to 9005.
Before After <Server port=”8005″ shutdown=”SHUTDOWN”> <Server port=”9005” shutdown=”SHUTDOWN”> - Http connector
Here the http connector port is 8080.
Now you have to change this port from 8080 to 8090.
Before After <Connector port=”8080″ protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″ URIEncoding=”UTF-8″ />
<Connector port=”8090” protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”9443” URIEncoding=”UTF-8″ />
- AJP connector
Here the AJP connector port is 8009.
Now you have to change this port from 8009 to 9009.
Before After <Connector protocol=”AJP/1.3″
address=”::1″
port=”8009″
redirectPort=”8443″ URIEncoding=”UTF-8″ />
<Connector protocol=”AJP/1.3″
address=”::1″
port=”9009“
redirectPort=”9443” URIEncoding=”UTF-8″ />
- Server port
- Start liferay-dxp-7.4.13.u60 → tomcat-9.0.65 → bin → startup (for Windows: batch file, and for Linux: shell script file)
- After the successful startup of Liferay, sign in to the site as an Admin.
- Sign in successfully with localhost:8090
- There are no error messages when starting two Liferays at the same time with different ports.