1. Installation and configuration of tomcat
1. In the server.xml file, modify the port of tomcat2. A total of 3 modifications need to be made, namely 8080, 8005 and 8009. Modified to 9080, 9005 and 9008 respectively.
After configuring this step, enter http://localhost:8080 and http://localhost:9080 in the browser to see the tomcat homepage.
2. nginx configuration to achieve load balancing.
2.1 Install pcre. Because the rewrite module of nginx requires pcre support, the pcre library needs to be installed.
2.1.1. Obtain the pcre compilation and installation package. The latest version can be obtained at http://www.pcre.org/
2.1.2. Unzip pcre-xx. tar.gz package.
2.1.3. Enter the decompression directory and execute ./configure.
2.1.4. make
2.1.5. make install
2.2 Install nginx. Since the nginx we want does not exist in the yum source, we need to create a yum source. The steps are as follows:
2.2.1. vim /etc/yum.repos.d/nginx.repo
Enter the following content, then save and exit.
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
2.2.2. Check whether the yum source is configured properly and execute the following command. If there is a result, the configuration is successful.
yum list |grep nginx
2.2.3. Install nginx.
yum -y install nginx
2.2.4. Configure nginx. Achieve load balancing. The main task is to configure the nginx.conf file and use the rpm -qc nginx command to query the location of the configuration file.
2.2.5 Check whether the configuration file is correct and restart nginx.
nginx -t service nginx restart 此处也可用如下命令: nginx -s reload
2.3 Verify the load balancing configuration
2.3.1 Modify the tomcat1 and tomcat2 homepage files respectively, obtain the login session id value, and add the h1 tag in the red box in the figure below
2.3.2 Enter: localhost:1210 in the browser and check whether the configuration is successful. You can see that you have jumped to the tomcat page and the configuration is successful.
#3. redis configuration, tomcat shared session.
3.1 Download and install redis3
3.1.1 Go to the redis official website to download redis3, the steps are omitted.
3.1.2 Unzip the file
tar -xvf redis-3.0.2.tar.gz
3.1.3 Compile and install.
cd redis-3.0.2 make make install ./utils/install_server.sh # 配置redis随机启动
3.1.4 Starting and shutting down redis.
service redis_6379 start #6379 is the default port number of redis. After modification according to requirements, the service name will change
service redis_6379 stop
service redis_6379 restart
3.2 Configure tomcat to share the redis-based session mechanism.
3.2.1 Copy the following three jar packages to tomcat's lib directory respectively:
commons-pool-1.3.jar jedis-2.0.0.jar tomcat-redis-session-manager-1.2-tomcat-7-java-7.jar
3.22 Modify the context.xml file in tomcat's conf directory, in the
<valve classname="com.radiadesign.catalina.session.redissessionhandlervalve" /> <manager classname="com.radiadesign.catalina.session.redissessionmanager" host="localhost" port="6379" database="0" maxinactiveinterval="60" />
3.3 Restart tomcat, enter localhost:1210 in the browser, and find that the sessions of tomcat1 and tomcat2 have been shared.
The above is the detailed content of Tomcat7 Nginx Redis configuration method under CentOS6.5. For more information, please follow other related articles on the PHP Chinese website!

NGINX can be used to improve website performance, security, and scalability. 1) As a reverse proxy and load balancer, NGINX can optimize back-end services and share traffic. 2) Through event-driven and asynchronous architecture, NGINX efficiently handles high concurrent connections. 3) Configuration files allow flexible definition of rules, such as static file service and load balancing. 4) Optimization suggestions include enabling Gzip compression, using cache and tuning the worker process.

NGINXUnit supports multiple programming languages and is implemented through modular design. 1. Loading language module: Load the corresponding module according to the configuration file. 2. Application startup: Execute application code when the calling language runs. 3. Request processing: forward the request to the application instance. 4. Response return: Return the processed response to the client.

NGINX and Apache have their own advantages and disadvantages and are suitable for different scenarios. 1.NGINX is suitable for high concurrency and low resource consumption scenarios. 2. Apache is suitable for scenarios where complex configurations and rich modules are required. By comparing their core features, performance differences, and best practices, you can help you choose the server software that best suits your needs.

Question: How to start Nginx? Answer: Install Nginx Startup Nginx Verification Nginx Is Nginx Started Explore other startup options Automatically start Nginx

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

To shut down the Nginx service, follow these steps: Determine the installation type: Red Hat/CentOS (systemctl status nginx) or Debian/Ubuntu (service nginx status) Stop the service: Red Hat/CentOS (systemctl stop nginx) or Debian/Ubuntu (service nginx stop) Disable automatic startup (optional): Red Hat/CentOS (systemctl disabled nginx) or Debian/Ubuntu (syst

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

The server does not have permission to access the requested resource, resulting in a nginx 403 error. Solutions include: Check file permissions. Check the .htaccess configuration. Check nginx configuration. Configure SELinux permissions. Check the firewall rules. Troubleshoot other causes such as browser problems, server failures, or other possible errors.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment