Skip to content

Instantly share code, notes, and snippets.

@pbkwee
Last active November 13, 2022 14:03
Show Gist options
  • Save pbkwee/1a4c5f9a0624c40125b9164a4476a509 to your computer and use it in GitHub Desktop.
Save pbkwee/1a4c5f9a0624c40125b9164a4476a509 to your computer and use it in GitHub Desktop.
Installing tomcat-native / libtcnative
wget 'http://www-eu.apache.org/dist/tomcat/tomcat-connectors/native/1.2.14/source/tomcat-native-1.2.14-src.tar.gz'
tar xzf tomcat-native-1.2.14-src.tar.gz
cd tomcat-native-1.2.14-src/native
apt install libapr1-dev libssl-dev gcc make
./configure && make && make install
Add to /usr/local/tomcat/bin/setenv.sh:
export CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=$PATH:/usr/local/apr/lib/"
On a mac: brew install libtcnative. Then add to $tomcat/bin/setenv.sh CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=/usr/local/opt/tomcat-native/lib"
in $tomcat/conf/server.xml enable this connector:
<Connector URIEncoding="UTF-8" port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
# ls -lrt /usr/local/apr/lib/
total 2960
drwxr-sr-x 2 root staff 4096 Oct 19 02:35 pkgconfig
-rwxr-xr-x 1 root staff 1103616 Oct 19 02:35 libtcnative-1.so.0.2.14
lrwxrwxrwx 1 root staff 23 Oct 19 02:35 libtcnative-1.so.0 -> libtcnative-1.so.0.2.14
lrwxrwxrwx 1 root staff 23 Oct 19 02:35 libtcnative-1.so -> libtcnative-1.so.0.2.14
-rwxr-xr-x 1 root staff 1041 Oct 19 02:35 libtcnative-1.la
-rw-r--r-- 1 root staff 1916200 Oct 19 02:35 libtcnative-1.a
If you need to create the rsa key/certs:
# openssl req -x509 -newkey rsa:4096 -keyout conf/localhost-rsa-key.pem -out conf/localhost-rsa-cert.pem -days 36500 -nodes -subj "/C=NZ/ST=Waikato/L=Cambridge/O=RimuHosting/OU=RimuHosting/CN=localhost"
@Rob801130
Copy link

wget 'http://www-eu.apache.org/dist/tomcat/tomcat-connectors/native/1.2.14/source/tomcat-native-1.2.14-src.tar.gz'
tar xzf tomcat-native-1.2.14-src.tar.gz
cd tomcat-native-1.2.14-src/native
apt install libapr1-dev libssl-dev gcc make
./configure && make && make install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment