RedHat 7 install and configure Tomcat 8

Source: Internet
Author: User

RedHat 7 install and configure Tomcat 8

RedHat 7 installs and configures Tomcat 8, and only JRE is installed without JDK ..

The test environment is as follows:

Operating System: Red Hat Enterprise Linux Server release 7.2 (Maipo), minimal installation

Tomcat: apache-tomcat-8.5.4.tar.gz

JRE: jre-8u102-linux-x64.rpm

1. Deploy Tomcat 8

By default, Tomcat 8.5 only needs JRE to run and does not need to install the complete JDK. In fact, this is the case from Tomcat 5.5. Tomcat 8.5 requires JRE 7 or a later version. See Tomcat 8.5's running.txt.

2. decompress the Tomcat 8.5.4 package, move it to the/usr/local directory, and run the startup script first. An error is reported that the JAVA environment variable is missing (in fact, if the rpm version of JRE is installed, you do not need to configure environment variables. In this article, no environment variables are configured and tomcat runs normally)

[Root @ rh7core tmp] # tar zxvf apache-tomcat-8.5.4.tar.gz

[Root @ rh7core tmp] # mv apache-tomcat-8.5.4/usr/local/

3. Check the Java version,Java-version, the prompt is not found, because I am using RedHat 7 to minimize installation, and java is not installed

4. Check the Java version after installing the rpm package of JRE 8.0 _ 102. This is normal.

5. Run the Tomcat 8.5.4 STARTUP script again.

6. Open the browser and enter http: // 192.168.10.11: 8080. The default page of Tomcat 8.5.4 is successfully opened.

2. Configure Tomcat service and set startup

Source of this article: Jiang jianlong technical blog http://jiangjianlong.blog.51cto.com/3735273/1854198

1. Edit the bin/catalina. sh file, specify catalina_PID, and add a line CATALINA_PID = "$ CATALINA_BASE/tomcat. pid" after the definition of CATALINA_BASE"

[Root @ rh7core bin] # vi catalina. sh

2. Create a Tomcat service,

[Root @ rh7core bin] # vi/lib/systemd/system/tomcat. service, add the following content

Note: The [unit] service description is configured, which is executed after the network is started. [Service] configure the service pid, service start, stop, and restart. [Install] the user is configured.

[Unit]

Description = Tomcat

After1_syslog.tar get network.tar get remote-fs.target nss-lookup.target

[Service]

Type = forking

PIDFile =/usr/local/apache-tomcat-8.5.4/tomcat. pid

ExecStart =/usr/local/apache-tomcat-8.5.4/bin/startup. sh

ExecReload =/bin/kill-s HUP $ MAINPID

ExecStop =/bin/kill-s QUIT $ MAINPID

PrivateTmp = true

[Install]

Wantedbypolicmulti-user.tar get

3. Test and stop the service and check the status.

4. Test the startup service and check the status

5. view the PID file. when the service is stopped, the PID file is automatically deleted. when the service is started, the PID file is automatically generated.

6. Set the tomcat service to automatically start when it is started

3. Configure Tomcat Manager background Logon

Source of this article: Jiang jianlong technical blog http://jiangjianlong.blog.51cto.com/3735273/1854198

1. Modify the vi tomcat-users configuration in the tomcat-users.xml, delete the annotator and the original role, user, and configure the role and user in the red box

2. You also need to modify the manager. xml file. If this file is not available, create the conf/Catalina/localhost/manager. xml file as follows. The allow value is the CIDR block that allows access to the Tomcat background.

[Root @ rh7core apache-tomcat-8.5.4] # cd conf/Catalina/localhost/

[Root @ rh7core localhost] # ls

[Root @ rh7core localhost] # vi manager. xml

<Context privileged = "true" antiResourceLocking = "false"

DocBase = "$ {catalina. home}/webapps/manager">

<Valve className = "org. apache. catalina. valves. RemoteAddrValve" allow = "192.168.10. *"/>

</Context>

3. After you modify manager. xml, you can log on to and access the Server Status and Manager APP without restarting tomcat. However, you cannot log on to Host Manager.

4. Configure the login Host Manager, modify the context. xml file under webapps/host-manager/META-INF, modify the allow parameters, the value of allow is to allow access to the Tomcat Host Manager network segment:Vi/usr/local/apache-tomcat-8.5.4/webapps/host-manager/META-INF/context. xml

<ContextantiResourceLocking = "false" privileged = "true">

<ValveclassName = "org. apache. catalina. valves. RemoteAddrValve"

Allow = "192.168.10. *"/>

</Context>

5. After modifying the context. xml parameter, you do not need to restart Tomcat to make the modification take effect. Click Host Manager to log on successfully.

3. Modify Tomcat Port

Source of this article: Jiang jianlong technical blog http://jiangjianlong.blog.51cto.com/3735273/1854198

1. Edit the conf/server. xml file and change the value of Connector port to 9090.

2. Restart Tomcat

[Root @ rh7core conf] # systemctl stop tomcat

[Root @ rh7core conf] # systemctl start tomcat

3. Access http: // 192.168.10.11: 9090 in a browser. The hosts page of Tomcat 8.5.4 is successfully opened.

4. Deploy a test website

Source of this article: Jiang jianlong technical blog http://jiangjianlong.blog.51cto.com/3735273/1854198

1. Upload the war package test. war of the website to the webapps directory in the tomcat directory. Tomcat loads all applications under Webapps and automatically decompress the war package to a folder of the same name.

2. Use a browser to access the test website http: // 192.168.10.11: 9090/test.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.