189 8069 5689

tengine+tomcat安装配置笔记

以前一直用glassfish, 从3到4, 省事倒是省事,就是太重了,图形界面配置过程中对cpu和内存的消耗较大,常遇到卡死的情况,虽然配置完成后,运行稳定,但还是决定放弃,改用tengine+tomcat。

合水网站建设公司创新互联,合水网站设计制作,有大型网站制作公司丰富经验。已为合水上千余家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的合水做网站的公司定做!

下载地址:http://tengine.taobao.org/

[2013-11-22]Tengine-1.5.2稳定版正式发布(变更列表)

tengine-1.5.2算是最新的稳定版

tomcat的设置可参见:http://my.oschina.net/u/221951/blog/372406

在安装tengine之前,确认centos环境中有无gcc、pcre、openssl,如果没有按以下命令进行安装

#yuminstallgcc #yum-yinstallpcre-devel 安装最新版本:pcre-devel-7.8-6.el6.i686 #yuminstallopenssl-devel 安装最新版本:openssl-devel-1.0.1e-30.el6_6.5.i686

开始安装tengine,注意确认有无nginx用户和app用户组,或者根据自身情况更改

#tar-vxzftengine-1.5.2.tar.gz #cdtengine-1.5.2 #./configure--prefix=/usr/local/nginx--user=nginx--group=app--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module--with-http_concat_module--with-http_upstream_check_module--with-http_sub_module--with-http_realip_module #make&&makeinstall

tengine自启动脚本

#vi/etc/rc.d/init.d/nginx

编辑脚本如下,注意配置目录的对应:

#!/bin/bash #nginxStartupscriptfortheNginxHTTPServer #itisv.0.0.2version. #chkconfig:-8515 #description:Nginxisahigh-performancewebandproxyserver. #Ithasalotoffeatures,butit\'snotforeveryone. #processname:nginx #pidfile:/var/run/nginx.pid #config:/usr/local/nginx/conf/nginx.conf nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/usr/local/nginx/logs/nginx.pid RETVAL=0 prog="nginx" #Sourcefunctionlibrary. ./etc/rc.d/init.d/functions #Sourcenetworkingconfiguration. ./etc/sysconfig/network #Checkthatnetworkingisup. [${NETWORKING}="no"]&&exit0 [-x$nginxd]||exit0 #Startnginxdaemonsfunctions. start(){ if[-e$nginx_pid];then echo"nginxalreadyrunning...." exit1 fi echo-n$"Starting$prog:" daemon$nginxd-c${nginx_config} RETVAL=$? echo [$RETVAL=0]&&touch/var/lock/subsys/nginx return$RETVAL } #Stopnginxdaemonsfunctions. stop(){ echo-n$"Stopping$prog:" killproc$nginxd RETVAL=$? echo [$RETVAL=0]&&rm-f/var/lock/subsys/nginx/usr/local/nginx/logs/nginx.pid } reload(){ echo-n$"Reloading$prog:" #kill-HUP`cat${nginx_pid}` killproc$nginxd-HUP RETVAL=$? echo } #Seehowwewerecalled. case"$1"in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status$prog RETVAL=$? ;; *) echo$"Usage:$prog{start|stop|restart|reload|status|help}" exit1 esac exit$RETVAL

接下来保存退出,变更文件权限,

#:wq #chmoda+x/etc/rc.d/init.d/nginx #chkconfig--addnginx #servicenginxrestart

编辑/user/local/nginx/conf/nginx.conf

#根据你服务器的cpu核数来确定此值 worker_processes4; error_loglogs/error.logcrit; #error_loglogs/error.lognotice; #error_loglogs/error.loginfo; #pidlogs/nginx.pid; worker_rlimit_nofile65535; #events事件主要用来确定Nginx使用哪种算法 events{ useepoll; worker_connections65535; } http{ includemime.types; default_typeapplication/octet-stream; #关闭httpheader中关于服务器的版本号 server_tokensoff; #log_formatmain\'$remote_addr-$remote_user[$time_local]"$request"\' #\'$status$body_bytes_sent"$http_referer"\' #\'"$http_user_agent""$http_x_forwarded_for"\'; #由于Nginx用于代理Tomcat,所以记录访问日志的事情交给Tomcat来做好了,注释掉 #access_loglogs/access.logmain; sendfileon; tcp_nopushon; tcp_nodelayon; #keepalive_timeout0; keepalive_timeout65; server_names_hash_bucket_size128; client_header_buffer_size32k; large_client_header_buffers432k; client_max_body_size3m; client_body_buffer_size512k; #代理的相关参数设置 proxy_connect_timeout5; proxy_read_timeout60; proxy_send_timeout5; proxy_buffer_size16k; proxy_buffers464k; proxy_busy_buffers_size128k; proxy_temp_file_write_size128k; #启用gzip压缩,提高用户访问速度 gzipon; gzip_min_length1k; gzip_buffers416k; gzip_http_version1.1; gzip_comp_level2; gzip_typestext/plainapplication/x-javascripttext/cssapplication/xml; gzip_varyon; #配置需要代理的tomcat upstreamtomcat_proxy{ ip_hash; session_sticky; server192.168.1.114:8080; } #虚拟主机:www.abc.com server{ listen80; server_namewww.abc.com; indexindex.htmlindex.htmindex.jsp; root/home/webapp/www/app1; if(-d$request_filename){ rewrite^/(.*)([^/])$http://$host/$1$2/permanent; } #动态页面,交给tomcat处理 location~.(jsp|jspx|do|action)?${ proxy_set_headerHost$host; proxy_set_headerX-Forwarded-For$remote_addr; proxy_passhttp://tomcat_proxy; } location/training/{ proxy_passhttp://tomcat_proxy; proxy_set_headerHost$host; proxy_set_headerX-Real-IP$remote_addr; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; #sub_filter/training//; } #用户浏览器端的缓存设置 location~.*.(gif|jpg|jpeg|png|bmp|swf)${ expires10d; } location~.*.(js|css)?${ expires1h; } access_logoff; #charsetkoi8-r; #access_loglogs/host.access.logmain; } }

设置确认没有问题,保存退出,可重启: service nginx restart


文章名称:tengine+tomcat安装配置笔记
转载来源:http://cdxtjz.cn/article/cpdcsh.html

其他资讯