博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tengine+tomcat+php安装
阅读量:6553 次
发布时间:2019-06-24

本文共 5179 字,大约阅读时间需要 17 分钟。

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

#yum install gcc#yum -y install pcre-devel安装最新版本:pcre-devel-7.8-6.el6.i686#yum install openssl-devel安装最新版本:openssl-devel-1.0.1e-30.el6_6.5.i686
开始安装tengine,注意确认有无nginx用户和app用户组,或者根据自身情况更改
#wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz#tar -vxzf tengine-2.1.2.tar.gz#cd tengine-2.1.2#groupadd app#useradd -g app nginx#./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#make install
tengine自启动脚本
#vi /etc/rc.d/init.d/nginx
编辑脚本如下,注意配置目录的对应:
#!/bin/bash# nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.# It has a lot of features, but it's not for everyone.# processname: nginx# pidfile: /var/run/nginx.pid# config: /usr/local/nginx/conf/nginx.confnginxd=/usr/local/nginx/sbin/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/usr/local/nginx/logs/nginx.pidRETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];thenecho "nginx already running...."exit 1fiecho -n $"Starting $prog: "daemon $nginxd -c ${nginx_config}RETVAL=$?echo[ $RETVAL = 0 ] && touch /var/lock/subsys/nginxreturn $RETVAL}# Stop nginx daemons functions.stop() {echo -n $"Stopping $prog: "killproc $nginxdRETVAL=$?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 -HUPRETVAL=$?echo}# See how we were called.case "$1" instart)start;;stop)stop;;reload)reload;;restart)stopstart;;status)status $progRETVAL=$?;;*)echo $"Usage: $prog {start|stop|restart|reload|status|help}"exit 1esacexit $RETVAL

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

#:wq#chmod a+x /etc/rc.d/init.d/nginx#chkconfig --add nginx#service nginx restart
编辑/usr/local/nginx/conf/nginx.conf
# 根据你服务器的cpu核数来确定此值,一般大于等于cpu核数worker_processes 2;	error_log logs/error.log crit;#error_log logs/error.log notice;#error_log logs/error.log info;	#pid logs/nginx.pid; 	worker_rlimit_nofile 65535; 	# events事件主要用来确定Nginx使用哪种算法 	events { 	    use epoll; 	    worker_connections 65535; 	} 	 	http { 	 include mime.types; 	 default_type application/octet-stream; 	  	 #关闭http header 中关于服务器的版本号 	 server_tokens  off; 	 	 #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 	 # '$status $body_bytes_sent "$http_referer" ' 	 # '"$http_user_agent" "$http_x_forwarded_for"'; 	 	 # 由于Nginx用于代理Tomcat,所以记录访问日志的事情交给Tomcat来做好了,注释掉 	 #access_log logs/access.log main; 	 	 sendfile on; 	 tcp_nopush on; 	 tcp_nodelay on; 	 	#keepalive_timeout 0; 	 keepalive_timeout 65; 	 	 server_names_hash_bucket_size 128; 	 client_header_buffer_size 32k; 	 large_client_header_buffers 4 32k; 	 client_max_body_size 3m; 	 client_body_buffer_size 512k; 	 	# 代理的相关参数设置 	 proxy_connect_timeout 5; 	 proxy_read_timeout 60; 	 proxy_send_timeout 5; 	 proxy_buffer_size 16k; 	 proxy_buffers 4 64k; 	 proxy_busy_buffers_size 128k; 	 proxy_temp_file_write_size 128k; 	 	# 启用gzip压缩,提高用户访问速度 	 gzip on; 	 gzip_min_length 1k; 	 gzip_buffers 4 16k; 	 gzip_http_version 1.1; 	 gzip_comp_level 2; 	 gzip_types text/plain application/x-javascript text/css application/xml; 	 gzip_vary on; 	 	# 配置需要代理的tomcat 	upstream tomcat_proxy{	   ip_hash;           session_sticky; 	   server localhost:8080 max_fails=3 weight=1 fail_timeout=60s; 	}         # 配置需要代理的apache 	upstream apache_proxy{	   ip_hash;           session_sticky; 	   server localhost:88 max_fails=3 weight=1 fail_timeout=60s; 	} 	 	# 虚拟主机:www.abc.com 	server { 	   listen 80; 	   server_name www.abc.com; 	   index index.html index.htm index.jsp; 	   root /home/webapp/www/app1; 	 	   if (-d $request_filename){ 	     rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent; 	   } 	 	   # 动态页面,交给tomcat处理 	   location ~ \.(jsp|jspx|do|action)?$ { 	     proxy_set_header Host $host; 	     proxy_set_header X-Forwarded-For $remote_addr; 	     proxy_pass http://tomcat_proxy; 	   }            # 动态页面,交给apache处理 	   location ~ \.(php)?$ { 	     proxy_set_header Host $host; 	     proxy_set_header X-Forwarded-For $remote_addr; 	     proxy_pass http://apache_proxy; 	   } 	   	   location /training/ {               proxy_pass        http://tomcat_proxy;              proxy_set_header  Host             $host;               proxy_set_header  X-Real-IP        $remote_addr;               proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;               #sub_filter        /training/          /;             }  	 	    # 用户浏览器端的缓存设置 	    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { 	      expires 7d; 	    } 	     	    location ~ .*\.(js|css)?$ { 	      expires 24h; 	    } 	     	     access_log off; 	     #charset koi8-r; 	     #access_log logs/host.access.log main; 	}}
设置确认没有问题,保存退出,可重启: service nginx restart

 

转载地址:http://juico.baihongyu.com/

你可能感兴趣的文章
什么是Shell脚本
查看>>
性能测试浅谈
查看>>
数据持久化以及沙盒路径
查看>>
2019 -2-15 复习
查看>>
ZeroMQ指南-前言 ...
查看>>
vim锁定屏幕
查看>>
IPv4选项
查看>>
FL2440 ubifs文件系统烧录遇到的问题——内核分区的重要性
查看>>
实用的 JavaScript 调试小技巧
查看>>
使用迭代器
查看>>
stm32模拟iic——引脚配置、代码
查看>>
用JavaScript探测页面上的广告是否被AdBlock屏蔽了的方法
查看>>
027移除元素
查看>>
Linux下清理内存和Cache方法
查看>>
CodeVS 1018 单词接龙(DFS)
查看>>
Android批量图片加载经典系列——Volley框架实现多布局的新闻列表
查看>>
我的博客园的CSS和html设置
查看>>
简单团队-爬取豆瓣电影TOP250-模块开发过程
查看>>
20145222《信息安全系统设计基础》第二周学习总结
查看>>
如何制作手绘地图?如何将图片图层精确地对准在地图上?
查看>>