Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:adm:server_preparation_win [2021/09/01 09:05]
fiserp [HTTPd installation and configuration]
tutorial:adm:server_preparation_win [2024/01/10 10:38] (current)
koulaj [Java]
Line 79: Line 79:
 <note>If you install the database onto a server distinct from the one on which the CzechIdM application itself (Tomcat etc.) is deployed, don't forget to configure PostgreSQL to allow remote SSL connection from that server.</note> <note>If you install the database onto a server distinct from the one on which the CzechIdM application itself (Tomcat etc.) is deployed, don't forget to configure PostgreSQL to allow remote SSL connection from that server.</note>
 ===== Java ===== ===== Java =====
-Install the openjdk (preferred version is 11.0.2). You can download it from [[https://jdk.java.net/archive/|here]]. Be sure to download the **JDK**, and not only **JRE**.  
  
 +Install the openjdk (preferred version is 11.0.2, for CzechIdm 13.1.0+ Java 21 is needed). You can download it from [[https://jdk.java.net/archive/|here]]. Be sure to download the **JDK**, and not only **JRE**.
 === OpenJDK Installation === === OpenJDK Installation ===
  
-Crete directory ''C:\Program Files\Java\'' and extract there downloaded zip. +Crete directory ''C:\Program Files\Java\'' and extract there downloaded zip. Then set path and JAVA HOME: 
-Then set path and JAVA HOME: + 
-  * Open the **sysdm.cpl** (Win+r ant type sysdm.cpl) dialogue and navigate to ''> Advanced > Environment Variables'' +   * Open the **sysdm.cpl**  (Win+r ant type sysdm.cpl) dialogue and navigate to ''> Advanced > Environment Variables'' 
-  * Add this line to PATH variable. <code>%JAVA_HOME%\bin</code>  +  * Add this line to PATH variable. 
-  * Add new variable ''JAVA_HOME'' with value ''C:\Program Files\Java\jdk-11.0.2'' +<code> 
-  * Then run ''java -version'' from the windows cmd to check if it is working properly.+ 
 +%JAVA_HOME%\bin 
 + 
 +</code> 
 + 
 +  * Add new variable ''JAVA_HOME''  with value ''C:\Program Files\Java\jdk-11.0.2'' 
 +  * Then run ''java -version''  from the windows cmd to check if it is working properly.
  
  
 ===== Tomcat ===== ===== Tomcat =====
 +
 Download and install the latest 9.0 branch of Apache Tomcat from [[https://tomcat.apache.org/download-90.cgi|here]]. Use the Windows installer. Download and install the latest 9.0 branch of Apache Tomcat from [[https://tomcat.apache.org/download-90.cgi|here]]. Use the Windows installer.
 +
   * Agree with licence agreement   * Agree with licence agreement
-  * Deselect ''Manager'' from components and click ''Next''+  * Deselect ''Manager''  from components and click ''Next''
   * Set shutdown port to "-1" and connector port to "8080" and click ''Next''   * Set shutdown port to "-1" and connector port to "8080" and click ''Next''
-  * Modify the ''JRE path'' to make it point to installed openjde **JDK** and click ''Next''+  * Modify the ''JRE path''  to make it point to installed openjde **JDK**  and click ''Next''
   * Leave the installation path on default and click ''Install''   * Leave the installation path on default and click ''Install''
   * When it's done deselect option "start tomcat" and click ''finish''.   * When it's done deselect option "start tomcat" and click ''finish''.
  
-You can also use Tomcat 9.0.45 and newer, those installers set the service account to ''Local Service'' themselves.</note>+You can also use Tomcat 9.0.45 and newer, those installers set the service account to ''Local Service''  themselves.</note>
  
-After installation, run the **Monitor Tomcat** application from the Start menu (or run ''Tomcat9w.exe'' from the Tomcat bin directory - usually ''C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin''). Configure following settings: +After installation, run the **Monitor Tomcat**  application from the Start menu (or run ''Tomcat9w.exe''  from the Tomcat bin directory - usually ''C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin''). Configure following settings:
-  * ''initial memory pool: 512MB'' (example for about 5GB RAM). +
-  * ''maximum memory pool: 4096MB'' (example for about 5GB RAM). +
-  * Add ''C:\CzechIdM\etc;C:\CzechIdM\lib;C:\CzechIdM\lib\*;'' to the **beginning of the** ''CLASSPATH''.+
  
-Configure addresses the server will listen on. Open the ''C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\server.xml'' configuration file in the Tomcat installation. Make these changes: +  * ''initial memory pool: 512MB''  (example for about 5GB RAM). 
-  * Add ''address="127.0.0.1"'' to the **8080/tcp** and **8009/tcp** connectors. This will make Tomcat listen only on localhost. +  * ''maximum memory pool: 4096MB''  (example for about 5GB RAM). 
-  * Change port number ''8005'' to ''-1'' at the Shutdown Port setting. This will effectively turn off the shutdown port. +  * Add ''C:\CzechIdM\etc;C:\CzechIdM\lib;C:\CzechIdM\lib\*;''  to the **beginning of the**''CLASSPATH''
-  * In the section for ''Connector protocol="HTTP/1.1"'' on port 8080, add the ''maxSwallowSize="-1"'' property. + 
-  * Uncomment the section ''Connector protocol="AJP/1.3"'' for the port 8009 and adjust the address parameter: ''address="127.0.0.1"'',''secretRequired="true"'' and ''secret="password for ajp port" ''. It should look like this:+Configure addresses the server will listen on. Open the ''C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\server.xml''  configuration file in the Tomcat installation. Make these changes: 
 + 
 +  * Add ''address="127.0.0.1"''  to the **8080/tcp**  and **8009/tcp**  connectors. This will make Tomcat listen only on localhost. 
 +  * Change port number ''8005''  to ''-1''  at the Shutdown Port setting. This will effectively turn off the shutdown port. 
 +  * In the section for ''Connector protocol="HTTP/1.1"''  on port 8080, add the ''maxSwallowSize="-1"''  property. 
 +  * Uncomment the section ''Connector protocol="AJP/1.3"''  for the port 8009 and adjust the address parameter: ''address="127.0.0.1"'',''secretRequired="true"''  and ''secret="password for ajp port" ''. It should look like this:
 <code> <code>
 +
     <Connector protocol="AJP/1.3"     <Connector protocol="AJP/1.3"
                address="127.0.0.1"                address="127.0.0.1"
Line 119: Line 130:
                secretRequired="true"                secretRequired="true"
                secret="***password for ajp port***"                secret="***password for ajp port***"
-               />    +               /> 
 </code> </code>
  
-Use the **services.msc** dialogue to set the Apache Tomcat ''StartupType'' to ''Automatic (Delayed Start)''. This will make the application container start after the PostgreSQL database. +Use the **services.msc**  dialogue to set the Apache Tomcat ''StartupType''  to ''Automatic (Delayed Start)''. This will make the application container start after the PostgreSQL database. <note important>For production use, we strongly advise to remove all Tomcat's management applications from the container. 
-<note important>For production use, we strongly advise to remove all Tomcat's management applications from the container. + 
-  * Locate the ''webapps'' folder in the Tomcat installation and delete everything that is inside.+  * Locate the ''webapps''  folder in the Tomcat installation and delete everything that is inside. 
 </note> </note>
  
-For roles and advanced management configuration, please see the relevant chapters in the [[tutorial:adm:server_preparation|Server Preparation - Linux]] tutorial.+For roles and advanced management configuration, please see the relevant chapters in the [[.:server_preparation|Server Preparation - Linux]] tutorial. 
 + 
 +==== Change Tomcat logging properties ==== 
 + 
 +In order to set-up log rotation we need stop logging to stdout and start logging to catalina.log . 
 + 
 +After change of these tomcat setting and setting-up **logback-spring.xml** in [[.:czechidm_installation_win#create_czechidm_configuration|create_czechidm_configuration]] IdM will log into catalina.out and after day rotate it into catalina.YYYY-MM-DD.log. Tomcat engine will log into tomcat.log and no totate because there are only log of tomat start. Tomcat will log logs of IdM connectors into tomcat-stdout tomcat9-stdout.YYYY-MM-DD.log - it's well knows bug with workaround to make manual log rotation. 
 + 
 +Make these changes in file ''C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\logging.properties'': Comment out console handler. We don't want tomcat to log to stdout or stderr and other unnesesary logs. 
 +<code> 
 + 
 +handlers = 1catalina.org.apache.juli.AsyncFileHandler 
 +#handlers =  java.util.logging.ConsoleHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler 
 + 
 +.handlers = 1catalina.org.apache.juli.AsyncFileHandler 
 +#.handlers = java.util.logging.ConsoleHandler, 
 + 
 +###2localhost.org.apache.juli.AsyncFileHandler.level = FINE 
 +###2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 
 +###2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost. 
 +###2localhost.org.apache.juli.AsyncFileHandler.maxDays = 90 
 +###2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8 
 + 
 +###3manager.org.apache.juli.AsyncFileHandler.level = FINE 
 +###3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 
 +###3manager.org.apache.juli.AsyncFileHandler.prefix = manager. 
 +###3manager.org.apache.juli.AsyncFileHandler.maxDays = 90 
 +###3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8 
 + 
 +###4host-manager.org.apache.juli.AsyncFileHandler.level = FINE 
 +###4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 
 +###4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager. 
 +###4host-manager.org.apache.juli.AsyncFileHandler.maxDays = 90 
 +###4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8 
 + 
 +###java.util.logging.ConsoleHandler.level = FINE 
 +###java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter 
 +###java.util.logging.ConsoleHandler.encoding = UTF-8 
 + 
 +#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO 
 +#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler 
 + 
 +#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO 
 +#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler 
 + 
 +#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO 
 +#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler 
 + 
 +</code> 
 + 
 +In 1catalina file handler change log level to "INFO" and prefix from "catalina" to "tomcat". Also set property rotable to "false". Tomcat write to this file only when starting or shutting down. 
 + 
 +<code> 
 +#1catalina.org.apache.juli.AsyncFileHandler.level = FINE 
 +#1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina. 
 +1catalina.org.apache.juli.AsyncFileHandler.level = INFO 
 +1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 
 +1catalina.org.apache.juli.AsyncFileHandler.prefix = tomcat 
 +1catalina.org.apache.juli.AsyncFileHandler.rotatable = false 
 +1catalina.org.apache.juli.AsyncFileHandler.suffix = .log 
 + 
 +</code> 
 + 
 +Then in file ''C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\server.xml'' remove creation of access logs. Coment out org.apache.catalina.valves.AccessLogValve.'' '' 
 +<code> 
 +    <!--   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
 +               prefix="localhost_access_log" suffix=".txt" 
 +               pattern="%h %l %u %t "%r" %s %b" /> --> 
 + 
 +</code> 
  
 ====== Apache httpd as a reverse proxy ====== ====== Apache httpd as a reverse proxy ======
  • by fiserp