Is it possible to tell tomcat to use a particular port instead of the one specified in server.xml? Or a way to configure an environment variable as port number in server.xml? (which I can set in a batch file which starts tomcat)
Essentially, I want to launch different copies (versions) of a tomcat instance without having to manually change the server.xml in each of them and having to remember which one would launch at which port. I wish to specify the port number when I launch it so that there is no conflict in the multiple instances.
Change your server.xml so that it will use port numbers expanded from properties instead of hardcoded ones:
<Server port="${port.shutdown}" shutdown="SHUTDOWN">
...
<Connector port="${port.http}" protocol="HTTP/1.1"/>
...
</Server>
Here's how you can start in Linux (assuming your current directory is CATALINA_HOME):
JAVA_OPTS="-Dport.shutdown=8005 -Dport.http=8080" bin/startup.sh
In windows it should be smth like following:
set "JAVA_OPTS=-Dport.shutdown=8005 -Dport.http=8080"
bin\startup.bat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With