真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

phpsessionmemcachetomcat

php session memcache tomcat


1,php編譯安裝
yum -y install libcurl-devel bzip2-devel  libxml2-devel mhash-devel libmcrypt-devel gcc

./configure --prefix=/usr/local/php --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --enable-fpm   --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-MySQL=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd

make && make install

cp php.ini-production /etc/php.ini

[root@node2 bin]# vim /etc/profile.d/lnmp.sh
export PATH=$PATH:/usr/local/php/bin

[root@node2 etc]# cp php-fpm.conf.default php-fpm.conf
[root@node2 etc]# vim php-fpm.conf
listen = /tmp/php-fpm

[root@node2 fpm]# pwd
/usr/local/php-5.4.26/sapi/fpm
[root@node2 fpm]# cp init.d.php-fpm /etc/init.d/php
[root@node2 fpm]# chmod u+x /etc/init.d/php
[root@node2 fpm]# service php start

2,安裝nginx
yum -y install nginx

 location ~ \.php$ {
        fastcgi_pass   unix://tmp/php-fpm;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /www/htdocs$fastcgi_script_name;
        include        fastcgi_params;
    }

service nginx start

[root@node2 php.d]# cat /www/htdocs/index.php
  phpinfo();
  ?>

3,yum -y install memcached
service memcached start

4,安裝php的memcache拓展
tar xf memcache-2.2.7.tgz
cd memcache-2.2.7
phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache
make && make install

[root@node2 memcache-2.2.7]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525
memcache.so

[root@node2 php.d]# echo 'extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so' >memcache.ini

vim /etc/php.ini
;session.save_handler = files
session.save_handler = memcache
session.save_path = "tcp://192.168.100.102:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

service php restart

新建php頁面setsess.php,為客戶端設(shè)置啟用session:
session_start();
if (!isset($_SESSION['www.MageEdu.com'])) {
  $_SESSION['www.MageEdu.com'] = time();
}
print $_SESSION['www.MageEdu.com'];
print "

";
print "Session ID: " . session_id();
?>

新建php頁面showsess.php,獲取當(dāng)前用戶的會(huì)話ID:
session_start();
$memcache_obj = new Memcache;
$memcache_obj->connect('172.16.200.11', 11211);
$mysess=session_id();
var_dump($memcache_obj->get($mysess));
$memcache_obj->close();
?>

-----------------
sessino保存到文件,可以掛一個(gè)共享的NFS就實(shí)現(xiàn)了session綁定

session.save_handler = files
session.save_path = "/tmp"

-------------------

jsp編譯,把嵌入了html代碼的jsp文件編譯成servlet能夠執(zhí)行的代碼
servlet執(zhí)行jsp編譯過的代碼,java面向cgi的實(shí)現(xiàn)
tomcat = jdk + servlet + jsp
jsp-->servlet-->class-->jvm
MVC架構(gòu):
Controller,Model和View各自獨(dú)立,一個(gè)流行的開源實(shí)現(xiàn)是Apache Structs框架;目今,設(shè)計(jì)優(yōu)良的Web應(yīng)用程序通常用相就的技術(shù)實(shí)現(xiàn)相應(yīng)的功能,比如:
1、Servlet用于實(shí)現(xiàn)應(yīng)用邏輯;
2、JSP用于內(nèi)容展示;
3、標(biāo)簽庫(kù)和JSP擴(kuò)展語言用于替換在JSP內(nèi)部嵌入Java代碼,進(jìn)而降低了HTML維護(hù)的復(fù)雜度;
4、MVC框架用于實(shí)現(xiàn)展示和應(yīng)用邏輯的分離;
C存在的目的則是確保M和V的同步,一旦M改變,V應(yīng)該同步更新。
現(xiàn)在我們總結(jié)MVC的處理過程,首先控制器接收用戶的請(qǐng)求,并決定應(yīng)該調(diào)用哪個(gè)模型來進(jìn)行處理,然后模型用業(yè)務(wù)邏輯來處理用戶的請(qǐng)求并返回?cái)?shù)據(jù),最后控制器用相應(yīng)的視圖格式化模型返回的數(shù)據(jù),并通過表示層呈現(xiàn)給用戶。
--------------
tomcat-session-memcached

1,安裝好兩臺(tái)tomcat,

創(chuàng)新互聯(lián)主要從事網(wǎng)站制作、成都網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)沙雅,十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220

#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
# JAVA_OPTS='-Xms64m -Xmx128m'
JAVA_HOME=/usr/java/lastest
CATALINA_HOME=/usr/local/tomcat
export JAVA_HOME CATALINA_HOME

case $1 in
start)
  exec $CATALINA_HOME/bin/catalina.sh start ;;
stop)
  exec $CATALINA_HOME/bin/catalina.sh stop;;
restart)
  $CATALINA_HOME/bin/catalina.sh stop
  sleep 2
  exec $CATALINA_HOME/bin/catalina.sh start ;;
*)
  echo "Usage: `basename $0` {start|stop|restart}"
  exit 1
  ;;
esac

修改配置文件
#vim server.xml
             unpackWARs="true" autoDeploy="true">
               

2,下載memcached-session-manager的jar包到/usr/local/tomcat/lib
memcached-session-manager項(xiàng)目地址,http://code.google.com/p/memcached-session-manager/

memcached-session-manager-${version}.jar            
memcached-session-manager-tc${6,7,8}-${version}.jar
spymemcached-${version}.jar                         
msm-javolution-serializer-${version}.jar            
javolution-${version}.jar                            

3,安裝好兩臺(tái)memcached,可以是一臺(tái),兩臺(tái)是為了高可用

4,修改tomcat配置文件,在中加
# vim /usr/local/tomcat/conf/context.xml

                memcachedNodes="n1:192.168.100.102:11211,n2:192.168.100.103:11211"
        requestUriIgnorePattern=".*/.(png|gif|jpg|css|js)$"
        sticky="false"
        sessionBackupAsync="false"
        sessionBackupTimeout="1800000"
        />
5,配置一個(gè)haproxy做輪詢的負(fù)載均衡

6,寫一個(gè)測(cè)試的頁面
# mkdir -pv /www/htdocs/test/WEB-INF/{classes,lib}
這個(gè)目錄要在上面的server.xml的host中定義好,當(dāng)然也可以是別的
[root@node3 ~]# vim /www/htdocs/test/index.jsp
<%@ page language="java" %>

  TomcatB
 
   

TomcatB.magedu.com


   
     
       
    <% session.setAttribute("magedu.com","magedu.com"); %>
       
     
     
       
       
    
   
Session ID<%= session.getId() %>
Created on<%= session.getCreationTime() %>

 


在另一個(gè)tomcat節(jié)點(diǎn)上
# mkdir -pv /www/htdocs/test/WEB-INF/{classes,lib}
[root@node2 ~]# vim /www/htdocs/test/index.jsp
<%@ page language="java" %>

  TomcatA
 
   

TomcatA.magedu.com


   
     
       
    <% session.setAttribute("magedu.com","magedu.com"); %>
       
     
     
       
       
    
   
Session ID<%= session.getId() %>
Created on<%= session.getCreationTime() %>

 


分享名稱:phpsessionmemcachetomcat
標(biāo)題網(wǎng)址:http://weahome.cn/article/jeojpg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部