Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Redis and Tomcat under Centos

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to install Redis and Tomcat under Centos". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install Redis and Tomcat under Centos.

Redis installation preparation

Execute the following command on the server to download the Redis package. You can ignore the first two steps and choose an appropriate directory by yourself:

Mkdir / root/redis (create a new directory as the installation directory for Redis) cd / root/redis (enter this directory) wget https://download.redis.io/releases/redis-6.0.13.tar.gz (download the Redis package to the currently open directory)

Or go here to select the appropriate version and place it on the server.

Decompress

When the download is complete, execute the following command:

Tar-zxvf redis-6.0.13.tar.gz (unzipped) mv redis-6.0.13 redis6 (renamed redis6, this directory is the Redis installation directory) cd redis6 (enter this installation directory) compile

In this step, you need to make sure that you have gcc on your server, because you need to compile with gcc, so you can use the following command to see if you have gcc on your server:

Gcc-v

If you have gcc on your server, we can see the content shown in the following figure:

Next, let's officially start the compilation, execute the following command and wait for it to finish:

Make

If successful, we will see what is shown in the following figure:

test

After the previous step is successful, we perform the following steps to test whether the Redis installation is successful:

Cd src (enter the src directory under the Redis installation directory). / redis-server (start Redis)

If successful, you will see something like the following figure:

Background start

If we start like this every time, we will not be able to execute other commands on the server unless Redis is aborted, so we do not want Redis to start in this way, so we will let it start in the background and execute the following command:

Cd / root/redis/redis6/src (enter src directory) mkdir conf (new configuration file directory) cp.. / redis.conf conf/ (copy a copy of its original configuration file to the newly created configuration file directory) vim conf/redis.conf (edit this configuration file): set nu (you must enter the command manually here, because it is a vim operation inside the file This command displays the line number of the file) then finds about 224 lines and changes daemonize no to daemonize yes (meaning that background is not allowed to run): wq (save leave). / redis-cli shutdown (close Redis to avoid port occupation). / redis-server conf/redis.conf (start Redis with the specified configuration file to test whether it becomes background running If successful, there will be no hint.) close Redis

Redis naturally shuts down after it starts. Here is the shutdown command for Redis:

Cd / root/redis/redis6/src (enter the src directory). / redis-cli shutdown (close Redis) remote connection

For security reasons, Redis itself does not recommend remote connection, but it can also be connected remotely. You only need to modify the contents of the configuration file redis.conf, as shown in the following figure:

All we have to do is comment out bind 127.0.0.1 or change it to bind 0.0.0.0, and after changing protected-mode yes to protected-mode no to save and exit, restart Redis with this configuration file. It is important to note that the port of redis can be set in the following lines of this figure, and this port must be open if it needs to be connected remotely.

Tomcat installation preparation

Download the Tomcat package and place it on the server, you can download it directly to the server with the following command:

Mkdir / root/tomcat (new directory placement package) cd / root/tomcatwget 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/ (enter the directory where the package is located) tar-zxvf apache-tomcat-8.5.66.tar.gz (unzip) mv apache-tomcat-8.5.66 tomcat8 (rename the directory name after decompression) modify the configuration file cd tomcat8 (enter the Tomcat installation directory) vim conf/server.xml (modify port and other information)

As shown in the figure above, you can find this location and modify the port. You only need to change 8080 to another port, save it and exit. You will not modify it here for the time being and use port 8080 directly.

Configure Tomcat environment variables

Execute the following command to configure the Tomcat environment variable:

Vim / etc/profile adds the following at the end of the file: expert CATALINA_HOME=/root/tomcat/tomcat8 (value is Tomcat installation directory) export PATH=$PATH:$ {CATALINA_HOME} / binsource / etc/profile (to make changes effective) Test Tomcat

Start Tomcat and execute the following command:

Startup.sh

Wait quietly for a while.

If you access it in a local browser, assuming that your server IP is 112.125.18.23, the address we will visit is 112.125.18.23. Enter directly. If Tomcat is installed and configured successfully, we will see the web page shown in the following figure:

Close Tomcat

Simply execute the following command:

Shutdown.sh so far, I believe you have a deeper understanding of "how to install Redis and Tomcat under Centos". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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: 226

*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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report