Install Redis and Tomcat on the server
Redis installation
Preparation
Execute the following command on the server to download the Redis compressed package. You can ignore the first two steps and do it yourself Just select a suitable directory:
mkdir /root/redis (新建目录作为Redis的安装目录)
cd /root/redis (进入这个目录)
wget https://download.redis.io/releases/redis-6.0.13.tar.gz (将Redis压缩包下载到当前打开的目录下)
Or go here to select the appropriate version and Place it on the server.
Unzip
After the download is complete, execute the following command:
tar -zxvf redis-6.0.13.tar.gz (解压缩)
mv redis-6.0.13 redis6 (改名为redis6,这个目录就是Redis的安装目录)
cd redis6 (进入这个安装目录)
Compile
In this step, you need to ensure that you have gcc on your server, because you need to use gcc to compile. We can use the following command to check whether you have gcc on your server:
gcc -v
If you have gcc on your server, we can see the content as shown below:
Continue Next we officially start compilation, execute the following command and wait for it to complete:
make
If successful, we will see the content as shown below:
Test
After the previous step is successful, we perform the following steps to test whether Redis is installed successfully:
cd src (进入Redis安装目录下的src目录)
-
./redis-server (启动Redis)
If successful, you will see something like the following picture:
Background startup
If this happens every time If started, we will not be able to continue executing other commands on the server unless Redis is stopped, so we do not want Redis to start in this way, then we have to let it start in the background and execute the following command:
cd /root/redis/redis6/src (进入src目录)
mkdir conf (新建配置文件目录)
cp ../redis.conf conf/ (将其原来的配置文件复制一份到刚刚新建的配置文件目录中)
vim conf/redis.conf (编辑这个配置文件)
:set nu (这里必须手动输入命令,因为是在文件内部里的vim操作,这个命令是显示文件的行号)
然后找到224行左右,将 daemonize no 修改为 daemonize yes (表示由不允许后台允许到允许后台运行)
:wq (保存离开)
./redis-cli shutdown (关闭一下Redis,以免发生端口占用)
./redis-server conf/redis.conf (以指定的配置文件启动Redis,测试其是否变成后台运行,成功的话是没有任何提示的)
Close Redis
Redis will naturally be shut down after it is started. The following is the shutdown command of Redis:
-
cd /root/redis/redis6/src (进入src目录)
./redis-cli shutdown (关闭Redis)
Remote connection
Redis itself does not recommend remote connection due to security issues, but it can also be connected remotely and only needs to be modified. The contents of the configuration file redis.conf are as shown below:
We only need to comment out bind 127.0.0.1 or modify it to bind 0.0.0.0, and then change protected Change -mode yes to protected-mode no. After saving and exiting, restart Redis with this configuration file. It should be noted that the redis port can be set in the following lines of this picture. If it needs to be connected remotely, this port must be open.
Tomcat installation
Preparation
Download the Tomcat compressed package and place it on the server. You can directly download it to the server through the following command:
mkdir /root/tomcat (新建目录放置压缩包)
cd /root/tomcat
wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.66/bin/apache-tomcat-8.5.66.tar.gz
You can also click here to download it locally and then upload it to the server.
Unzip
cd /root/tomcat/ (进入压缩包所在目录)
tar -zxvf apache-tomcat-8.5.66.tar.gz (解压缩)
mv apache-tomcat-8.5.66 tomcat8 (重命名解压后的目录名)
Modify the configuration file
cd tomcat8 (进入Tomcat安装目录)
vim conf/server.xml (修改端口等信息)
As shown in the picture above, find this location and modify the port. You only need to modify 8080 to another port. Just save and exit. There will be no modifications here for the time being. Use port 8080 directly.
Configure Tomcat environment variables
Execute the following command to configure Tomcat environment variables:
vim /etc/profile
在文件末尾加入以下内容: expert CATALINA_HOME=/root/tomcat/tomcat8 (值为Tomcat安装目录) export PATH=$PATH:${CATALINA_HOME}/bin
source /etc/profile (使修改生效)
Test Tomcat
Start Tomcat and execute the following command:
startup.sh
Wait quietly for a while...
Access in a local browser, assuming your server IP is 112.125.18.23, then the address we are going to access is 112.125.18.23:8080 , just press Enter. If Tomcat is installed and configured successfully, we will see the web page as shown below:
Close Tomcat
Just execute the following command:
shutdown.sh
The above is the detailed content of How to install Redis and Tomcat under Centos. For more information, please follow other related articles on the PHP Chinese website!

Redis plays a key role in data storage and management, and has become the core of modern applications through its multiple data structures and persistence mechanisms. 1) Redis supports data structures such as strings, lists, collections, ordered collections and hash tables, and is suitable for cache and complex business logic. 2) Through two persistence methods, RDB and AOF, Redis ensures reliable storage and rapid recovery of data.

Redis is a NoSQL database suitable for efficient storage and access of large-scale data. 1.Redis is an open source memory data structure storage system that supports multiple data structures. 2. It provides extremely fast read and write speeds, suitable for caching, session management, etc. 3.Redis supports persistence and ensures data security through RDB and AOF. 4. Usage examples include basic key-value pair operations and advanced collection deduplication functions. 5. Common errors include connection problems, data type mismatch and memory overflow, so you need to pay attention to debugging. 6. Performance optimization suggestions include selecting the appropriate data structure and setting up memory elimination strategies.

The applications of Redis in the real world include: 1. As a cache system, accelerate database query, 2. To store the session data of web applications, 3. To implement real-time rankings, 4. To simplify message delivery as a message queue. Redis's versatility and high performance make it shine in these scenarios.

Redis stands out because of its high speed, versatility and rich data structure. 1) Redis supports data structures such as strings, lists, collections, hashs and ordered collections. 2) It stores data through memory and supports RDB and AOF persistence. 3) Starting from Redis 6.0, multi-threaded I/O operations have been introduced, which has improved performance in high concurrency scenarios.

RedisisclassifiedasaNoSQLdatabasebecauseitusesakey-valuedatamodelinsteadofthetraditionalrelationaldatabasemodel.Itoffersspeedandflexibility,makingitidealforreal-timeapplicationsandcaching,butitmaynotbesuitableforscenariosrequiringstrictdataintegrityo

Redis improves application performance and scalability by caching data, implementing distributed locking and data persistence. 1) Cache data: Use Redis to cache frequently accessed data to improve data access speed. 2) Distributed lock: Use Redis to implement distributed locks to ensure the security of operation in a distributed environment. 3) Data persistence: Ensure data security through RDB and AOF mechanisms to prevent data loss.

Redis's data model and structure include five main types: 1. String: used to store text or binary data, and supports atomic operations. 2. List: Ordered elements collection, suitable for queues and stacks. 3. Set: Unordered unique elements set, supporting set operation. 4. Ordered Set (SortedSet): A unique set of elements with scores, suitable for rankings. 5. Hash table (Hash): a collection of key-value pairs, suitable for storing objects.

Redis's database methods include in-memory databases and key-value storage. 1) Redis stores data in memory, and reads and writes fast. 2) It uses key-value pairs to store data, supports complex data structures such as lists, collections, hash tables and ordered collections, suitable for caches and NoSQL databases.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools