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)
![Startup file in bin folder of Liferay tomcat | Start two or more Liferay servers simultaneously on a machine Startup file in bin folder of Liferay tomcat](https://www.ignek.com/wp-content/uploads/2024/03/Startup-file-in-bin-folder-of-Liferay-tomcat-1024x538.webp)
- After the successful startup of liferay, Sign in to the site as an Admin.
- Sign in successfully with localhost:8080
![Admin home screen of Liferay | Start two or more Liferay servers simultaneously on a machine Admin home screen of Liferay](https://www.ignek.com/wp-content/uploads/2024/03/Admin-home-screen-of-Liferay-1024x529.webp)
- Next, open the Global Menu (◧) .Then navigate to Control Panel → Configuration → System Settings.
![navigate to Control Panel | Start two or more Liferay servers simultaneously on a machine navigate to Control Panel](https://www.ignek.com/wp-content/uploads/2024/03/navigate-to-Control-Panel-1024x469.webp)
- Click on System Settings → Platform section → click on the Search.
![Exploring system setting in control panel | Start two or more Liferay servers simultaneously on a machine Exploring system setting in control panel](https://www.ignek.com/wp-content/uploads/2024/03/Exploring-system-setting-in-control-panel-1024x567.webp)
- Click on Search, open a new tab, and look like the below image:
![Exploring search in system setting | Start two or more Liferay servers simultaneously on a machine Exploring search in system setting](https://www.ignek.com/wp-content/uploads/2024/03/Exploring-search-in-system-setting-1024x520.webp)
- 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.
![Change Elasticsearch HTTP port | Start two or more Liferay servers simultaneously on a machine Change Elasticsearch HTTP port](https://www.ignek.com/wp-content/uploads/2024/03/Change-Elasticsearch-HTTP-port-1024x518.webp)
- Restart the Liferay. Check Liferay starts with new Elasticsearch at the new port.
![Liferay restart with new Elasticsearch port | Start two or more Liferay servers simultaneously on a machine Liferay restart with new Elasticsearch port](https://www.ignek.com/wp-content/uploads/2024/03/Liferay-restart-with-new-Elasticsearch-port-1024x547.webp)
- 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
![Locating server file in conf folder of Liferay tomcat | Start two or more Liferay servers simultaneously on a machine Locating server file in conf folder of Liferay tomcat](https://www.ignek.com/wp-content/uploads/2024/03/Locating-server-file-in-conf-folder-of-Liferay-tomcat-1024x226.webp)
- 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)
![Launch Liferay on Tomcat startup script | Start two or more Liferay servers simultaneously on a machine Launch Liferay on Tomcat startup script](https://www.ignek.com/wp-content/uploads/2024/03/Launch-Liferay-on-Tomcat-startup-script-1024x557.webp)
- After the successful startup of Liferay, sign in to the site as an Admin.
- Sign in successfully with localhost:8090
![Liferay startup success at 8090 port | Start two or more Liferay servers simultaneously on a machine Liferay startup success at 8090 port](https://www.ignek.com/wp-content/uploads/2024/03/Liferay-startup-success-at-8090-port-1024x527.webp)
- There are no error messages when starting two Liferays at the same time with different ports.
![Fiest Liferay logs to check running smoothly on different ports | Start two or more Liferay servers simultaneously on a machine Fiest Liferay logs to check running smoothly on different ports](https://www.ignek.com/wp-content/uploads/2024/03/Fiest-Liferay-logs-to-check-running-smoothly-on-different-ports-1024x438.webp)
![Second Liferay logs with default port | Start two or more Liferay servers simultaneously on a machine Second Liferay logs with default port](https://www.ignek.com/wp-content/uploads/2024/03/Second-Liferay-logs-with-default-port-1024x443.webp)