eclipse 匯出的 .war 檔, 放到 web server 的 tomcat webapp 目錄後, 修改 tomcat/conf/server.xml 後, 就可以上架 web server.
server.xml 修改 connector:
<Connector port="80" protocol="HTTP/1.1"
redirectPort="443"
disableUploadTimeout="false"/>
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="conf/keystore.jks" keystorePass="your-password"
clientAuth="false" acceptCount="100"/>
在 server.xml 最後的 <host> tag 裡加入
<Context docBase="/path/file.war" path="" reloadable="true" />
如果有需要的話, 要開防火牆:
sudo firewall-cmd --zone=public --permanent --add-port=80/tcp
sudo firewall-cmd --zone=public --permanent --add-port=443/tcp
sudo firewall-cmd --reload
附註: 80,443 預設會被系統鎖住, 一般程式無法bind, 參考解法:
https://stackoverflow.max-everyday.com/2023/11/permission-denied-error-when-binding-a-port/
附註:在 tomcat 9.0.89 版本之後,server.xml 的寫法有修改,請參考看看:
The HTTP Connector
https://tomcat.apache.org/tomcat-9.0-doc/config/http.html
certificateKeystoreFile | The pathname of the keystore file where you have stored the server certificate and key to be loaded. By default, the pathname is the file .keystore in the operating system home directory of the user that is running Tomcat. If your keystoreType doesn’t need a file use "" (empty string) or NONE for this parameter. Relative paths will be resolved against $CATALINA_BASE . A URI may also be used for this attribute. When using a domain keystore (keystoreType of DKS ), this parameter should be the URI to the domain keystore.This attribute is required unless certificateFile is specified. |
certificateKeystorePassword | The password to use to access the keystore containing the server’s private key and certificate. If not specified, a default of changeit will be used. |
相關文章
如何在eclipse升級tomcat 版本
https://stackoverflow.max-everyday.com/2023/10/how-to-upgrade-tomcat-version-in-eclipse/