1. Instalación del servidor Tomcat y VSFTP , certificados y librerias
1. Elección del servidor
Se elige una máquina Ubuntu Server (sin interface gráfica).
2. Instalación de Tomcat
/home/informatica/MyPrograms
Se instalará la versión de Tomcat 10 que haya en el repositorio y se puede también instalar en la misma carpeta de arriba (/home/informatica/MyPrograms/tomcat10) por ejemplo
2.1 Fichero bin/setenv.bat
Crear el archivo bin/setenv.bat en la carpeta del Tomcat con este contenido, para que busque la ruta de java, en la carpeta donde se ha instalado.
export JAVA_HOME=/home/informatica/MyPrograms/jdk-17.0.2+9.OpenJ9
2.2 Fichero de configuración conf/context.xml
<Context antiResourceLocking="false" privileged="true" > <!--<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />--> </Context>
<Context antiResourceLocking="false" privileged="true" > <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.0.1|127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> </Context>
2.3 Fichero de configuración de usuarios conf/tomcat-users
Hay que activar el usuario tomcat con el rol de "manager-gui", y darle la contraseña adecuada<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="mypassword" roles="tomcat,manager-gui"/>
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="mypassword" roles="tomcat,manager-gui"/>
3. Instalación del certificado de servidor en el Tomcat
3.1 Fichero de configuracion "conf/server.xml"
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html --> <Server port="8005" shutdown="SHUTDOWN"> --> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!-- APR library loader. Documentation at /docs/apr.html --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html --> <Service name="Catalina"> <!--The connectors can use a shared executor, you can define one or more named thread pools--> <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> --> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : HTTP Connector: /docs/config/http.html AJP Connector: /docs/config/ajp.html Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 --> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" Server =" " redirectPort="8443" /> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2 This connector uses the NIO implementation. The default SSLImplementation will depend on the presence of the APR/native library and the useOpenSSL attribute of the AprLifecycleListener. Either JSSE or OpenSSL style configuration may be used regardless of the SSLImplementation selected. JSSE style configuration is used below. --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true"> <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /> <SSLHostConfig> <Certificate certificateKeystoreFile="conf/localhost-rsa.jks" type="RSA" /> </SSLHostConfig> </Connector> --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true"> <SSLHostConfig> <Certificate certificateKeystoreFile="/home/eduard/CERTS_SERVER/ACCV/ssl_wildcard.tavernes.es.jks" type="RSA" clientAuth="false" sslProtocol="TLS" keystorePass="JJWE99"/> </SSLHostConfig> </Connector> --> <!-- Define an SSL Coyote HTTP/1.1 Connector on port 8443 --> <Connector protocol="org.apache.coyote.http11.Http11NioProtocol" port="8443" maxThreads="150" SSLEnabled="true"><SSLHostConfigtruststorePassword="xxxxxxxx" certificateVerification="required" >
truststoreFile="/home/informatica/MyKeystores/ACCV/cacerts"
<Certificate certificateKeystoreFile="/home/informatica/MyKeystores/ACCV/ssl_wildcard.tavernes.es.jks" certificateKeystorePassword="MY_PASSWORD" type="RSA" /> </SSLHostConfig> </Connector> <Connector protocol="org.apache.coyote.http11.Http11NioProtocol" port="19443" maxThreads="150" SSLEnabled="true"> <SSLHostConfig<Certificate certificateKeystoreFile="/home/informatica/MyKeystores/ACCV/ssl_wildcard.ajuntament.es.jks" certificateKeystorePassword="MY_PASSWORD" type="RSA" /> </SSLHostConfig> </Connector> <!-- <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keyAlias="ssl_profile" keystoreFile="/home/informatica/MyKeystores/ACCV/ssl_wildcard.ajuntament.es.p12" keystorePass="MY_PASSWORD" keystoreType="PKCS12" truststoreFile="/home/informatica/MyKeystores/ACCV/mytruststore.jks" truststorePass="MY_OTHER_PASSWORD" truststoreType="JKS" /> --> <!-- Define an AJP 1.3 Connector on port 8009 --> <!-- <Connector protocol="AJP/1.3" address="::1" port="8009" redirectPort="8443" /> --> <!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). Documentation at /docs/config/engine.html --> <!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> --> <Engine name="Catalina" defaultHost="localhost"> <!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server>truststoreFile="/home/informatica/MyKeystores/ACCV/cacerts"truststorePassword="xxxxxxxx" certificateVerification="required" >
4. Ojo quitar esta línea del server.xml para los puertos 8443 i 19443
5.Copiar el fichero lib/security/cacerts que está dentro de la instacion de java a la carpeta
/home/informatica/MyKeystores/ACCV/
A contiuación descargar los certificados raiz de la ACCV, FNMT, DNIe, .. y de las autoridades de certificacion reconocidas y guardarlos en un directorio
con Keystore Explorer abrir el fichero cacert e importar ls certificados raiz descargados (tools - import trusted certificate)
4. Quitar la aplicación de inicio y otras mas
5. Arrancar y parar tomcat
5.1 Manualmente
# Arrancar el servidortomcat ./startup.sh # Parar el servidor tomcat ./shutdown.sh
5.2 Como servicio
sudo addgroup tomcat
sudo useradd tomcat -g tomcat
A continuación hay que asignar a tomcat al grupo de informatica y el usuario informática hay
que asignarle el gupo tomcat pues parece ser que tomcat arranca con el usuario tomcat
sudo usermod -a -G informatica tomcat
sudo usermod -a -G tomcat informatica
A continuación se debe de cambiar los permisos de este fichero para que sea ejecutable
sudo chmod +x /etc/init.d/tomcat10
A continuació se arrancan los servicios
sudo update-rc.d tomcat10 defaults
Para arrancar o parar manualmente
service tomcat10 [start | stop]
Para eliminar el servicio
sudo update-rc.d -f tomcat10 remove
Si acaso no funcionara (intenta arrancar y se para) seguramente será un tema de permisos. Y se procede así:
1. La carpeta logs del tomcat tien que tener permiso a escritura, por tanto cambiar el permiso de dicha carpeta a ug+w y así se podrá escribir el fichero catalina.out que nos indicara donde falla el proceso
2. Verificar que los permisos de las carpetas del tomcat sean:
drwxrwxr-x 5 informatica informatica 4096 nov 16 16:15 ..
drwxr-x--x 2 informatica informatica 4096 nov 14 12:23 bin
-rwxr-x--x 1 informatica informatica 20021 oct 3 16:18 BUILDING.txt
drwxr-x--x 3 informatica informatica 4096 nov 17 08:23 conf
-rwxr-x--x 1 informatica informatica 6210 oct 3 16:18 CONTRIBUTING.md
drwxr-x--x 2 informatica informatica 4096 nov 9 11:02 lib
-rwxr-x--x 1 informatica informatica 60269 oct 3 16:18 LICENSE
drwxrwx--x 2 informatica informatica 4096 nov 17 14:19 logs
-rwxr-x--x 1 informatica informatica 2333 oct 3 16:18 NOTICE
-rwxr-x--x 1 informatica informatica 3398 oct 3 16:18 README.md
-rwxr-x--x 1 informatica informatica 6908 oct 3 16:18 RELEASE-NOTES
-rwxr-x--x 1 informatica informatica 16515 oct 3 16:18 RUNNING.txt
drwxr-x--x 2 informatica informatica 4096 nov 9 11:02 temp
drwxr-x--x 8 informatica informatica 4096 nov 16 19:16 webapps
drwxr-x--x 3 informatica informatica 4096 nov 14 13:45 work
6. Asignar el dominio a la IP
7. Despliegue de la aplicación en el servidor en el Tomcat
8. Instalar el servidor VSFPT
9. Instalar librerías que faltan
sudo apt-get update
sudo apt-get install libxrender1
sudo apt-get install libxtst6
sudo apt-get install libxi6 libgconf-2-4
Comentarios
Publicar un comentario