To modify the port number of Tomcat, you need to edit the Tomcat configuration file server.xml
, which is located conf
in the directory of Tomcat. The following are the specific steps:
-
Connect to your Linux server using Terminal or SSH.
-
Enter
conf
the directory of Tomcat. By default, Tomcat'sconf
directory is located in the subdirectory of the Tomcat installation directoryconf
.cd /path/to/tomcat/conf
-
Open the file with a text editor such as
vi
or .nano
server.xml
vi server.xml
-
In the opened
server.xml
file, find the following line, which is Tomcat's default HTTP connector configuration:<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
By default, Tomcat uses port 8080 as the port number for the HTTP connector.
-
Modify
port
the value of the attribute to the port number you want, for example, to 8081:<Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
-
Save changes and exit the editor.
-
Restart the Tomcat service to make the configuration take effect.
./startup.sh
Tomcat's HTTP connector will now use the new port number you specified. Please make sure that the new port number is not occupied by other processes or services, otherwise Tomcat will not start normally. After completing the above steps, you can access Tomcat by accessing the new port number through a browser. For example, if you change the port number to 8081, you can http://your_server_ip:8081
access Tomcat through .