検索
ホームページデータベースRedisnginx+tomcat で Redis セッション共有を使用する方法

環境の準備

1. nginx サーバー ip192.168.1.133 ポート 81 を準備します

インストール プロセス:

#首先安装依赖:
yum -y install gcc-c++ 
yum -y install pcre pcre-devel 
yum -y install zlib zlib-devel 
yum -y install openssl openssl—devel
#注意 : 安装nginx必须使用 root 用户安装
#创建一个nginx目录
mkdir /usr/local/src/nginx
#进入到nginx目录
cd /usr/local/src/nginx
#下载或上传安装包
wget http://nginx.org/download/nginx.tar.gz 或 rz上传
#解压安装包
tar -xvf nginx.tar.gz
#进入到解压后的目录
cd nginx
# 下面 才开始正式安装
#把nginx安装到指定用户的目录
mkdir -p /ucenter/soft/nginx
#安装配置 prefix为安装目录 user为用户 group为 组
./configure --prefix=/ucenter/soft/nginx --user=ucenter --group=ucenter
#编译
make 
#安装
make install
#在linux系统中由于非root用户不能占用80端口,所以需要使普通用户以root身份启动nginx。 
cd /ucenter/soft/nginx/sbin
#把soft文件下所有的文件所属者修改为ucener -r 表示递归
chown ucenter:ucenter ./soft/ -r
#修改 ./nginx 的所属为root
chown root nginx
#让普通用户可以使用80端口,可以使用root权限启用nginx
chmod u+s nginx
#修改配置文件 在修改配置文件之前 ,要备份该文件
cd conf/
# 要注意nginx 的工作进程,一般根据cpu的核数去修改
vim nginx.conf
#关闭防火墙,打开80端口
service iptables stop
#启动nginx
./nginx
#重启nginx
./nginx -s reload
#关闭nginx
./nginx -s stop

Tomcat サーバーを準備します。最初に Java 環境を準備し、JDK インストール手順を省略します。

次に、3 つの Tomcat サーバー IP アドレスをインストールします: 192.168.1.143、tomcat1 ポート 8080、tomcat2 8081 ポート、tomcat3 ポート 8082 。

nginx+tomcat怎么使用redis session共享

apache-tomcat-7.0.64/conf/server.xml 設定ファイル ポートが競合しないように、これら 3 つの場所を変更します。

<server port="8005" shutdown="shutdown">
<connector port="8080" protocol="http/1.1"
connectiontimeout="20000"
redirectport="8443" />
<connector port="8009" protocol="ajp/1.3" redirectport="8443" />

Tomcat ルート ディレクトリの Index.jsp を変更し、各 Tomcat の ID を追加し、ページにセッション ID を表示します

<%--
licensed to the apache software foundation (asf) under one or more
contributor license agreements. see the notice file distributed with
this work for additional information regarding copyright ownership.
the asf licenses this file to you under the apache license, version 2.0
(the "license"); you may not use this file except in compliance with
the license. you may obtain a copy of the license at

 http://www.apache.org/licenses/license-2.0

unless required by applicable law or agreed to in writing, software
distributed under the license is distributed on an "as is" basis,
without warranties or conditions of any kind, either express or implied.
see the license for the specific language governing permissions and
limitations under the license.
--%>
<!doctype html>
<%@ page session="true" %>
<%
java.text.simpledateformat sdf = new java.text.simpledateformat("yyyy");
request.setattribute("year", sdf.format(new java.util.date()));
request.setattribute("tomcaturl", "http://tomcat.apache.org/");
request.setattribute("tomcatdocurl", "/docs/");
request.setattribute("tomcatexamplesurl", "/examples/");
%>
<html>
 <head>
  <title><%=request.getservletcontext().getserverinfo() %></title>
  <link href="favicon.ico" rel="icon" type="image/x-icon" />
  <link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />
  <link href="tomcat.css" rel="stylesheet" type="text/css" />
 </head>

 <body>
  <div id="wrapper">
   <div id="navigation" class="curved container">
    <span id="nav-home"><a href="${tomcaturl}">home--<%=request.getsession().getid() %></a></span>
    <span id="nav-hosts"><a href="${tomcatdocurl}">documentation</a></span>
    <span id="nav-config"><a href="${tomcatdocurl}config/">configuration</a></span>
    <span id="nav-examples"><a href="${tomcatexamplesurl}">examples</a></span>
    <span id="nav-wiki"><a href="http://wiki.apache.org/tomcat/frontpage">wiki</a></span>
    <span id="nav-lists"><a href="${tomcaturl}lists.html">mailing lists</a></span>
    <span id="nav-help"><a href="${tomcaturl}findhelp.html">find help</a></span>
    <br />
   </div>
   <div id="asf-box">
    <h1 id="pagecontext-servletcontext-serverinfo">${pagecontext.servletcontext.serverinfo}--8080</h1>
   </div>
   <div id="upper" class="curved container">
    <div id="congrats" class="curved container">
     <h2 id="if-nbsp-you-re-nbsp-seeing-nbsp-this-nbsp-you-ve-nbsp-successfully-nbsp-installed-nbsp-tomcat-nbsp-congratulations">if you&#39;re seeing this, you&#39;ve successfully installed tomcat. congratulations!</h2>
    </div>
    <div id="notice">
     <img src="/static/imghwm/default1.png"  data-src="tomcat.png"  class="lazy"   alt="[tomcat logo]" />
     <div id="tasks">
      <h3 id="recommended-nbsp-reading">recommended reading:</h3>
      <h4 id="a-nbsp-href-tomcatdocurl-security-howto-html-security-nbsp-considerations-nbsp-how-to-a"><a href="${tomcatdocurl}security-howto.html">security considerations how-to</a></h4>
      <h4 id="a-nbsp-href-tomcatdocurl-manager-howto-html-manager-nbsp-application-nbsp-how-to-a"><a href="${tomcatdocurl}manager-howto.html">manager application how-to</a></h4>
      <h4 id="a-nbsp-href-tomcatdocurl-cluster-howto-html-clustering-session-nbsp-replication-nbsp-how-to-a"><a href="${tomcatdocurl}cluster-howto.html">clustering/session replication how-to</a></h4>
     </div>
    </div>
    <div id="actions">
     <div>
      <a class="container shadow" href="/manager/status"><span>server status</span></a>
     </div>
     <div>
      <a class="container shadow" href="/manager/html"><span>manager app</span></a>
     </div>
     <div>
      <a class="container shadow" href="/host-manager/html"><span>host manager</span></a>
     </div>
    </div>
    <!--
    <br />
    -->
    <br />
   </div>
   <div id="middle" class="curved container">
    <h3 id="developer-nbsp-quick-nbsp-start">developer quick start</h3>
    <div>
     <div>
      <p><a href="${tomcatdocurl}setup.html">tomcat setup</a></p>
      <p><a href="${tomcatdocurl}appdev/">first web application</a></p>
     </div>
    </div>
    <div>
     <div>
      <p><a href="${tomcatdocurl}realm-howto.html">realms & aaa</a></p>
      <p><a href="${tomcatdocurl}jndi-datasource-examples-howto.html">jdbc datasources</a></p>
     </div>
    </div>
    <div>
     <div>
      <p><a href="${tomcatexamplesurl}">examples</a></p>
     </div>
    </div>
    <div>
     <div>
      <p><a href="http://wiki.apache.org/tomcat/specifications">servlet specifications</a></p>
      <p><a href="http://wiki.apache.org/tomcat/tomcatversions">tomcat versions</a></p>
     </div>
    </div>
    <br />
   </div>
   <div id="lower">
    <div id="low-manage" class="">
     <div class="curved container">
      <h3 id="managing-nbsp-tomcat">managing tomcat</h3>
      <p>for security, access to the <a href="/manager/html">manager webapp</a> is restricted.
      users are defined in:</p>
      <pre class="brush:php;toolbar:false">$catalina_home/conf/tomcat-users.xml
      

in tomcat 7.0 access to the manager application is split between        different users.   read more...

      
      

release notes

      

changelog

      

migration guide

      

security notices

               
     
      

documentation

      

tomcat 7.0 documentation

      

tomcat 7.0 configuration

      

tomcat wiki

      

find additional important configuration information in:

      
$catalina_home/running.txt
      

developers may be interested in:

            
    
    
     
      

getting help

      

faq and mailing lists

      

the following mailing lists are available:

      
           
  • tomcat-announce
            important announcements, releases, security vulnerability notifications. (low volume).
           
  •        
  • tomcat-users
            user support and discussion        
  •        
  • taglibs-user
            user support and discussion for apache taglibs        
  •        
  • tomcat-dev
            development mailing list, including commit messages        
  •       
     
    
    
       
    
     
      

other downloads

            
    
    
     
      

other documentation

            
    
    
     
      

get involved

            
    
    
     
      

miscellaneous

            
    
    
     
      

apache software foundation

            
    
    
   
   

copyright ©1999-${year} apache software foundation. all rights reserved

    

以上がnginx+tomcat で Redis セッション共有を使用する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明
この記事は亿速云で複製されています。侵害がある場合は、admin@php.cn までご連絡ください。
Redis:そのアーキテクチャと目的を理解するRedis:そのアーキテクチャと目的を理解するApr 26, 2025 am 12:11 AM

Redisは、主にデータベース、キャッシュ、メッセージブローカーとして使用されるメモリデータ構造ストレージシステムです。そのコア機能には、シングルスレッドモデル、I/O多重化、持続メカニズム、複製、クラスタリング機能が含まれます。 Redisは、キャッシュ、セッションストレージ、メッセージキューのための実際のアプリケーションで一般的に使用されます。適切なデータ構造を選択し、パイプラインとトランザクションを使用し、監視とチューニングを使用することにより、パフォーマンスを大幅に改善できます。

Redis vs. SQLデータベース:重要な違​​いRedis vs. SQLデータベース:重要な違​​いApr 25, 2025 am 12:02 AM

RedisデータベースとSQLデータベースの主な違いは、Redisが高性能および柔軟性要件に適したインメモリデータベースであることです。 SQLデータベースは、複雑なクエリとデータの一貫性要件に適したリレーショナルデータベースです。具体的には、1)Redisは高速データアクセスとキャッシュサービスを提供し、キャッシュおよびリアルタイムのデータ処理に適した複数のデータ型をサポートします。 2)SQLデータベースは、テーブル構造を介してデータを管理し、複雑なクエリとトランザクション処理をサポートし、データの一貫性を必要とするeコマースや金融システムなどのシナリオに適しています。

Redis:データストアとサービスとしてどのように機能するかRedis:データストアとサービスとしてどのように機能するかApr 24, 2025 am 12:08 AM

redisactsassassadatastoreandaservice.1)asadatastore、itusesin memorystorage for fastorations、supporting variousdatastructureSlike-key-valuepairsandsortedsets.2)asaservice、iteasruascruascriptingrupting criptingforceptingpurplecomplecomplecprexoperations

Redis vs.その他のデータベース:比較分析Redis vs.その他のデータベース:比較分析Apr 23, 2025 am 12:16 AM

他のデータベースと比較して、Redisには次の独自の利点があります。1)非常に速い速度、および読み取り操作は通常、マイクロ秒レベルにあります。 2)豊富なデータ構造と操作をサポートします。 3)キャッシュ、カウンター、公開サブスクリプションなどの柔軟な使用シナリオ。 Redisまたはその他のデータベースを選択する場合、特定のニーズとシナリオに依存します。 Redisは、高性能および低遅延のアプリケーションでうまく機能します。

Redisの役割:データストレージと管理機能の調査Redisの役割:データストレージと管理機能の調査Apr 22, 2025 am 12:10 AM

Redisは、データストレージと管理において重要な役割を果たしており、複数のデータ構造と持続性メカニズムを通じて最新のアプリケーションの中核となっています。 1)Redisは、文字列、リスト、コレクション、注文されたコレクション、ハッシュテーブルなどのデータ構造をサポートし、キャッシュや複雑なビジネスロジックに適しています。 2)RDBとAOFの2つの持続方法を通じて、Redisは信頼できるストレージとデータの迅速な回復を保証します。

Redis:NOSQLの概念の理解Redis:NOSQLの概念の理解Apr 21, 2025 am 12:04 AM

Redisは、大規模なデータの効率的なストレージとアクセスに適したNOSQLデータベースです。 1.Redisは、複数のデータ構造をサポートするオープンソースメモリデータ構造ストレージシステムです。 2.キャッシュ、セッション管理などに適した、非常に速い読み取り速度と書き込み速度を提供します。 4.使用例には、基本的なキー値ペア操作と高度なコレクション重複排除関数が含まれます。 5.一般的なエラーには、接続の問題、データ型の不一致、メモリオーバーフローが含まれるため、デバッグに注意する必要があります。 6.パフォーマンス最適化の提案には、適切なデータ構造の選択とメモリ排除戦略の設定が含まれます。

Redis:実際のユースケースと例Redis:実際のユースケースと例Apr 20, 2025 am 12:06 AM

現実世界でのRedisのアプリケーションには、1。キャッシュシステムとして、データベースクエリを加速し、2。Webアプリケーションのセッションデータを保存するには、3。リアルタイムランキングを実装する4。メッセージ配信をメッセージキューとして簡素化する。 Redisの汎用性と高性能により、これらのシナリオで輝きます。

Redis:その機能と機能の調査Redis:その機能と機能の調査Apr 19, 2025 am 12:04 AM

Redisは、高速、汎用性、豊富なデータ構造のために際立っています。 1)Redisは、文字列、リスト、コレクション、ハッシュなどのデータ構造をサポートし、コレクションを注文します。 2)メモリを介してデータを保存し、RDBとAOFの持続性をサポートします。 3)Redis 6.0から始めて、マルチスレッドI/O操作が導入されました。これにより、高い並行性シナリオでパフォーマンスが向上しました。

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

このプロジェクトは osdn.net/projects/mingw に移行中です。引き続きそこでフォローしていただけます。 MinGW: GNU Compiler Collection (GCC) のネイティブ Windows ポートであり、ネイティブ Windows アプリケーションを構築するための自由に配布可能なインポート ライブラリとヘッダー ファイルであり、C99 機能をサポートする MSVC ランタイムの拡張機能が含まれています。すべての MinGW ソフトウェアは 64 ビット Windows プラットフォームで実行できます。

DVWA

DVWA

Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、