In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to build CentOS7 server Tomcat, I hope you will learn something after reading this article, let's discuss it together!
Tomcat download address: http://tomcat.apache.org/download-80.cgi
Install it in the opt directory and make a soft link
Wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gztar-xzvf apache-tomcat-8.5.14.tar.gzmkdir / opt/tomcat/ opt/tomcat/tomcat8.5mv apache-tomcat-8.5.14 / opt/tomcat/tomcat8.5/ln-s / opt/tomcat/tomcat8.5/apache-tomcat-8.5.14 / opt/tomcat/tomcat8.5/default / / create tomcat8.5 default soft link ln-s / opt/tomcat/tomcat8.5/default / opt/tomcat/default / / create system default tomcat soft link rm-rf / opt/tomcat/tomcat8.5/apache-tomcat-8.5.14/webapps/ {docs Examples,host-manager,manager ROOT} / / Delete the file chown root:root-R / opt/tomcat / / owner set to rootchmod go+rX-R / opt/tomcat / / under webapps Add read and execute permissions to groups and other users It is convenient for users to start tomcat. Vim / opt/tomcat/tomcat8.5/apache-tomcat-8.5.14/conf/server.xml / / removes the comments in this file, making it easier to modify the configuration later when you configure multiple instances. (optional)
Create a user home directory
Mkdir / data/tomcat
Create a user
Useradd-d / data/tomcat/jspxcms jspxcms / /-d specifies the home directory usermod-s / sbin/nologin jspxcms / / users are not allowed to log in to shell:-s / sbin/nologinpasswd jspxcms / / change the password chmod Umurw / data / tomcat/jspxcms / / remove write permissions from the user's home directory Otherwise, when vsftp is set to chroot_local_user=YES, you will not be able to log in to chown jspxcms:nginx / data/tomcat/jspxcms / / modify the user group to which the home directory belongs to nginx, so that nginx can access the user home directory chmod g+rX / data/tomcat/jspxcms / / user directory to allow group members to enter, which is convenient for nginx access.
Prepare what is needed for CATALINA_BASE
Cd / data/tomcat/jspxcms mkdir {logs,work,temp,webapps,webapps/ROOT,backup} / / create a required folder. Backup as the backup folder cp-R / opt/tomcat/default/conf. / / copy the configuration file chown-R jspxcms:jspxcms * / / set the directory owner
Modify the conf/server.xml file
Shutdown port 8005 is changed to-1.
Delete the AJP Connector port= "8009" configuration.
Delete the access log org.apache.catalina.valves.AccessLogValve configuration.
Modify port 8080 to 10001
AutoDeploy is changed to false. Turn off automatic deployment. Automatic deployment refers to automatic reload after classes changes are detected.
Connector optimizable options. There is basically no need for optimization, and there is no obvious change after optimization.
MaxThreads: maximum number of threads. Default is 200. It is generally sufficient, and high concurrency can reach 400. Should not be too large, thread switching is also a waste of performance.
MaxConnections: maximum number of connections. The default value of NIO and NIO2 is 8192. It's usually enough. It can be increased appropriately according to the maxThreads value.
AcceptCount: the queued request that can be accepted after the number of maxConnections is reached. The default is 100. Requests that exceed this value are rejected. Generally speaking, it is OK by default, but it is not very useful. It can be increased to 200 or 400.
Modify conf/loggin.properties
# keep only one handlershandlers = java.util.logging.ConsoleHandleropenssl
To install openssl-1.1.0 source code download: https://www.openssl.org/source/
The version of openssl-1.0.1e installed by yum is too low to compile tomcat native.
Wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz / / download tar-xzvf openssl-1.1.0e.tar.gz / / decompress mv openssl-1.1.0e / usr/local/src/ need to decompress to `/ usr/local/ src` directory Otherwise, cd / usr/local/src/openssl-1.1.0eyum install zlib-devel gcc./config shared zlib--prefix=/usr/local/opensslmake & make installmv / usr/bin/openssl / usr/bin/openssl.oldmv / usr/include/openssl / usr/include/openssl.old / / ignore ln-s / usr/local/openssl/bin/openssl / usr/bin/opensslln-s / usr/local/openssl/include if it does not exist. / openssl/ usr/include/opensslecho "/ usr/local/openssl/lib" > > / etc/ld.so.confldconfig-vopenssl versiontomcat native
Reference document: http://tomcat.apache.org/native-doc/
Yum install apr-devel / / installation depends on cd / opt/tomcat/tomcat8.5/apache-tomcat-8.5.14/bin/tar-xzvf tomcat-native.tar.gzcd tomcat-native-1.2.12-src/native./configure-- with-apr=/usr/bin/apr-1-config\-- with-java-home=/opt/java/default/\ -- with-ssl=/usr/local/openssl\-- prefix=/opt/tomcat/default/make & & make install / / compiled files in this directory: $CATALINA_HOME/lib
Create an native environment variable
Cd / opt/tomcat/tomcat8.5/apache-tomcat-8.5.14/bincp setclasspath.sh setenv.shchown root:tomcat setenv.shvim setenv.sh
The content is modified to
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/libexport LD_LIBRARY_PATH self-starting
Create a startup script
Vim / usr/lib/systemd/system/tomcat_jspxcms.service
Start the script content
[Unit] Description=Apache TomcatAfter=syslog.target network.target [service] Type=forkingEnvironment= "JAVA_HOME=/opt/java/default" # sets java memory. Solve the problem that createSecureRandom takes a long time. Environment= "CATALINA_OPTS=-Xms200M-Xmx350M-Djava.security.egd=file:/dev/./urandom-Duser.dir=/data/tomcat/jspxcms" Environment= "CATALINA_HOME=/opt/tomcat/default" Environment= "CATALINA_BASE=/data/tomcat/jspxcms" # default UMASK is 0027, which is set to 0022 in order to be accessible by nginx. Environment= "UMASK=0022" ExecStart=/opt/tomcat/default/bin/startup.shExecStop=/opt/tomcat/default/bin/shutdown.shUser=jspxcmsGroup= jspxcms [install] WantedBy=multi-user.target
Start the service
Systemctl daemon-reloadsystemctl enable tomcat_jspxcmssystemctl start tomcat_jspxcms has finished reading this article, I believe you have a certain understanding of "how to build Tomcat on CentOS7 server". If you want to know more about it, please follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.