CentOS-6.5安装配置Tengine
為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??
一、安裝pcre:
cd /usr/local/src wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz tar zxvf pcre-8.37.tar.gz cd pcre-8.37 ./configure --prefix=/usr/local/pcre make make install
二、下載proxy_cache插件
cd /usr/local/srcwget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gztar zxvf ngx_cache_purge-2.3.tar.gz三、安裝tengine
yum install openssl openssl-devel -y cd /usr/local/src wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz tar zxvf tengine-2.1.0.tar.gz cd tengine-2.1.0 ./configure --add-module=/usr/local/src/ngx_cache_purge-2.3 --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/usr/local/src/pcre-8.37 make make install
如果編譯的問(wèn)題的話,看看是不是下面的原因:
./configure: error: the HTTP SSL module requires OpenSSL library原因:安裝http_ssl_module模塊需要openssl library解決:yum install openssl-devel ./configure: error: the HTTP rewrite module requires the PCRE library.原因:安裝http_rewrite_module模塊需要先安裝PCRE開(kāi)發(fā)包解決:yum install pcre-devel
?
注意:
--with-pcre=/usr/local/src/pcre-8.37指向的是源碼包解壓的路徑,而不是安裝的路徑,否則會(huì)報(bào)錯(cuò)。
?--add-module=/usr/local/src/ngx_cache_purge-2.3 是指加載緩存的插件模塊
四、設(shè)置Tengine開(kāi)機(jī)啟動(dòng)
vi /etc/rc.d/init.d/nginx? #編輯啟動(dòng)文件添加下面內(nèi)容
#!/bin/bash # Tengine Startup script# processname: nginx # chkconfig: - 85 15 # description: nginx is a World Wide Web server. It is used to serve # 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"# 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 "tengine 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 1 esac exit $RETVAL?保存退出
chmod 775 /etc/rc.d/init.d/nginx #賦予文件執(zhí)行權(quán)限 chkconfig --level 012345 nginx on #設(shè)置開(kāi)機(jī)啟動(dòng) /etc/rc.d/init.d/nginx restart五、配置Tengine
將nginx初始配置文件備份,我們要重新創(chuàng)建配置文件. mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak創(chuàng)建nginx用戶nginx
groupadd nginx useradd -g nginx nginx編輯主配置文件:
vi /usr/local/nginx/conf/nginx.conf內(nèi)容如下:
user www www; worker_processes 4; # 工作進(jìn)程數(shù),為CPU的核心數(shù)或者兩倍 error_log logs/error.log crit; # debug|info|notice|warn|error|crit pid logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 65535; events { use epoll; #Linux最常用支持大并發(fā)的事件觸發(fā)機(jī)制 worker_connections 65535; } http { include mime.types; #設(shè)定mime類型,類型由mime.type文件定義 default_type application/octet-stream;charset utf-8;log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';access_log logs/access.log main; #設(shè)定請(qǐng)求緩沖 server_names_hash_bucket_size 256; #增加,原為128 client_header_buffer_size 256k; #增加,原為32k large_client_header_buffers 4 256k; #增加,原為32k #size limits client_max_body_size 10m; #允許客戶端請(qǐng)求的最大的單個(gè)文件字節(jié)數(shù) client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; server_tokens on; #不顯示nginx版本信息 limit_conn_zone $binary_remote_addr zone=perip:10m; #添加limit_zone,限制同一IP并發(fā)數(shù) #fastcgi_intercept_errors on; #開(kāi)啟錯(cuò)誤頁(yè)面跳轉(zhuǎn) include gzip.conf; #壓縮配置文件 include proxy.conf; #proxy_cache參數(shù)配置文件 include vhost/*.conf; #nginx虛擬主機(jī)包含文件目錄 include mysvrhost.conf; #后端WEB服務(wù)器列表文件 }編輯代理配置文件:
cd /usr/local/nginx/conf/ mkdir vhost vi /usr/local/nginx/conf/proxy.conf
內(nèi)容如下:
#注:proxy_temp_path和proxy_cache_path指定的路徑必須在同一分區(qū) proxy_temp_path /tmp/proxy_temp;#設(shè)置Web緩存區(qū)名稱為cache_one,內(nèi)存緩存空間大小為500MB,1天沒(méi)有被訪問(wèn)的內(nèi)容自動(dòng)清除,硬盤(pán)緩存空間大小為30GB。 proxy_cache_path /tmp/proxy_cache levels=1:2 keys_zone=cache_one:500m inactive=1d max_size=30g;client_body_buffer_size 512k; #原為512k proxy_connect_timeout 50; #代理連接超時(shí) proxy_read_timeout 600; #代理發(fā)送超時(shí) proxy_send_timeout 600; #代理接收超時(shí) proxy_buffer_size 128k; #代理緩沖大小,原為32k proxy_buffers 16 256k; #代理緩沖,原為4 64k proxy_busy_buffers_size 512k; #高負(fù)荷下緩沖大小,原為128k proxy_temp_file_write_size 1024m; #proxy緩存臨時(shí)文件的大小原為128k #proxy_ignore_client_abort on; #不允許代理端主動(dòng)關(guān)閉連接 proxy_next_upstream error timeout invalid_header http_500 http_503 http_404 http_502 http_504;編輯主機(jī)配置文件:
內(nèi)容如下:
編輯壓縮配置文件:
內(nèi)容如下:
編輯配置文件:
內(nèi)容如下:
為T(mén)engine配置一下系統(tǒng)的TCP設(shè)置,優(yōu)化一下:
內(nèi)容如下:
net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.tcp_sack = 1 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_rmem = 4096 87380 4194304 net.ipv4.tcp_wmem = 4096 16384 4194304 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 262144 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 30 net.ipv4.ip_local_port_range = 1024 65000#允許系統(tǒng)打開(kāi)的端口范圍使配置立即生效
制作一個(gè)重啟全部的腳本
內(nèi)容如下:
#!/bin/sh##重啟memcached進(jìn)程 service memcached restart#清空日志 rm -f /usr/local/tomcat1/logs/* rm -f /usr/local/tomcat2/logs/*#清空緩存 rm -rf /tmp/proxy_cache#重啟動(dòng)tomcat /usr/local/tomcat1/bin/shutdown.sh /usr/local/tomcat2/bin/shutdown.sh/usr/local/tomcat1/bin/startup.sh /usr/local/tomcat2/bin/startup.sh#重啟nginx service nginx restart
給運(yùn)行權(quán)限
chmod 777 /root/restartall 以后重啟服務(wù)只需要: /root/restartall轉(zhuǎn)載于:https://my.oschina.net/boltwu/blog/490874
總結(jié)
以上是生活随笔為你收集整理的CentOS-6.5安装配置Tengine的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: HDOJ 4883 TIANKENG’s
- 下一篇: .htm .html .shtml的区别