Choice of Web Application Server *
(1) IBM WebLogic for WebSphere and Oracle
High performance, but also high price *
(2) Tomcat
High cost performance
Tomcat server is a free open source Web application server, belongs to the lightweight application server, in small and medium-sized systems and concurrent access users are not widely used, is the first choice to develop and debug JSP programs. In general, although Tomcat and Apache or nginx these Web servers, with the ability to handle HTML pages, but due to processing static HTML is far less than Apache or Nginx, So tomcat is usually used as a servlet and JSP container, running on the back end alone.
Case Environment
A apche or Nginx Web server, two Tomcat servers.
Experimental process:
One, Tomcat server 1
1. Turn off the firewall or set up firewall rules
2. You must install the JDK before you install Tomcat. The full name of the JDK is Java Development Kit, a free Java language Software Development Toolkit for Sun, which includes a Java Virtual machine (JVM).
Unpack the JDK package, and the Jdk1.7.0_65 folder will be generated when the decompression is complete, and the Jdk1.7.0_65 folder can be moved to/usr/local and renamed to Java.
3. Create a java.sh script under/ETC/PROFILE.D
vim/etc/profile.d/java.sh
4: Import the java.sh script into the environment variable to make it effective
Run the java-version command or the javac-version command to see if the Java version is consistent with the previous installation
The Java environment is now configured to complete.
5. Install Tomcat
6. After unpacking, generate the apache-tomcat-7.0.54 folder, move the folder to/usr/local, and rename it to TOMCAT7
7. Start Tomcat to see the port number
8. Open the browser to test
Tomcat Configuration related Instructions
Tomcat's home directory is/USR/LOCAL/TOMCAT7
(1) Main catalogue description
| ---bin/: script file to start and close Tomcat on Windows or Linux platforms
| ---conf/: A variety of global configuration files for the Tomcat server, the most important of which is server.xml and Web. xml
| ---lib/: library file (JARS) to store tomcat operations
| ---logs/: Storage log file for tomcat execution
| ---webapps:tomcat's main Web publishing directory (including application examples)
| ---work: Store the class file generated by JSP compilation
(2) configuration file description
Catalina.policy: Permission Control profile
Catalina.properties:Tomcat Property configuration file
Context.xml: Context configuration file
Logging.properties: Log logs related configuration file
Server.xml: Master configuration file
Tomcat-users.xml:manager-gui Managing User Profiles
Web.xml:Tomcat servlet, servlet-mapping, filter, MIME and other related configurations
9. Build a Java Web site
(1) First set up a web directory under the root directory, and create a WEBAPP1 directory inside, for storing web site files
(2) Create a index.jsp test page in the WEBAPP1 directory
(3) Modify Tomcat's Server.xml file to add a context segment to the host segment
(4) Turn Tomcat off, on reboot
(5) Access via browser
Second, Tomcat server 2
The Tomcat 2 server configuration method is basically the same as Tomcat 1, which includes
Close Iptables Firewall
Installing the JDK, configuring the Java environment
Installation configuration Tomcat
(1) Create the/WEB/WEBAPP1 directory, modify the configuration file Server.xml, change the site file directory to/web/webapp1/Path
Mkdir-pv/web/webapp1
(2) in the/web/webapp1/path to establish index.jsp, in order to distinguish the test page index.jsp content more vim/web/webapp1/index.jsp
more/web/webapp1/index.jsp
(3) Modify Tomcat's Server.xml file
(4) Turn Tomcat off, on reboot
! [] (http://i2.51cto.com/images/blog/201810/09/bc61680b77d8be999! [] (http://i2.51cto.com/images/blog/201810/09/af62233f02a406e9ad26f82b39f5506e.jpg?x-oss-process=image/ watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=)
Third, configure Nginx server
(1) Close iptables firewall
(2) Install the relevant package 1 turn off the firewall.
(3) Check if DK is installed. The Java version is maintained with the Tarcat Sever, (31 installs the configuration Tomcat. Version is consistent with TORCAT1 server.
(4) Create the/WEB/WEBAPP1 directory, modify the Tomcat configuration file sever XML to change the Web site file directory to/web/webapp1/path.
(5) Create an index JSP under the/web/webapp1/path. To differentiate the content of the test page index JSP, change the following
vim/web/webapp1/index.jsp
2.
3. Set up users and groups, unzip and install Nginx
4. Parameter meaning:
-user=,--group= specifying which users and groups to run
-with-file-aio Enable file modification support
-with-http_stub_status_module Enable status statistics
-with-http_gzip_static_module enabling gzip static compression
-with-http_flv_module Enable FLV module, providing time-based offset files seeking memory usage
- -with-http_ssl_module Enable SSL Module
5. Configure nginx.conf
6. (1) in HTTP {...} Add the following code to set the server list for load balancing, the weight parameter represents the weight value, the higher the weight, the greater the probability of being allocated. In order to make the test effect more obvious, here the weight value is set to the same
(2 Add a row in the HTTP {...}-server {...}-location/{...}
7. Test the Nginx configuration file is correct
8. Start the Nginx service
9. View Nginx Service Process
10. View port and PID process number
11. Test Load Balancing effect
Tomcat and load Balancing