成人AV在线无码|婷婷五月激情色,|伊人加勒比二三四区|国产一区激情都市|亚洲AV无码电影|日av韩av无码|天堂在线亚洲Av|无码一区二区影院|成人无码毛片AV|超碰在线看中文字幕

nginx,tomcat,Java部署

linux 下部署:1、JDK 安裝與配置2、數(shù)據(jù)庫安裝3、tomcat 安裝與配置4、nginx 安裝與配置一、JDK 安裝./jdk1.6.0_45.bin配置環(huán)境變量vi /etc/profi

linux 下部署:

1、JDK 安裝與配置

2、數(shù)據(jù)庫安裝

3、tomcat 安裝與配置

4、nginx 安裝與配置

一、JDK 安裝

./jdk1.6.0_45.bin

配置環(huán)境變量

vi /etc/profile

#set Java environment

export JAVA_HOME=/usr/local/src/jdk1.6.0_45

export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin

[root@admin local]#source /etc/profile

二、數(shù)據(jù)庫安裝

三、tomcat 安裝與配置

[root@admin local]# tar -zxv -f apache-tomcat-7.0.42.tar.gz // 解壓壓縮包

提供執(zhí)行權(quán):[root@admin local]# chmod -x apache-tomcat-7.0.42/bin/*.sh

配置優(yōu)化:

內(nèi)存優(yōu)化:

JAVA_OPTS="-server -Xms512M -Xmx512M -Xss512k -XX: AggressiveOpts -XX: UseBiasedLocking -XX:PermSize=128M -XX:MaxPermSize=128M -XX: DisableExplicitGC -XX:MaxTenuringThreshold=31 -XX: UseConcMarkSweepGC -XX: UseParNewGC -XX: CMSParallelRemarkEnabled -XX: UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX: UseFastAccessorMethods -XX: UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true"

線程池配置:

vi /conf/server.xml

maxThreads="500" minSpareThreads="20" maxIdleTime="60000" />

參數(shù):

maxThreads:Tomcat可創(chuàng)建的最大的線程數(shù),每一個(gè)線程處理一個(gè)請(qǐng)求;

minSpareThreads:最小備用線程數(shù),tomcat 啟動(dòng)時(shí)的初始化的線程數(shù);

,

maxSpareThreads:最大備用線程數(shù),一旦創(chuàng)建的線程超過這個(gè)值,T omcat 就會(huì)關(guān)閉不再需要的socket 線程;

acceptCount:指定當(dāng)所有可以使用的處理請(qǐng)求的線程數(shù)都被使用時(shí),可以放到處理隊(duì)列中的請(qǐng)求數(shù),就是被排隊(duì)的請(qǐng)求數(shù),超過這個(gè)數(shù)的請(qǐng)求將拒絕連接。

connnectionTimeout:網(wǎng)絡(luò)連接超時(shí),單位:毫秒。設(shè)置為0表示永不超時(shí),這樣設(shè)置有隱患的。通常可設(shè)置為30000毫秒。

enableLookups:是否允許DNS 查詢

連接相關(guān)Connector 的參數(shù)與配置

port="8080" protocol="HTTP/1.1"

connectionTimeout="20000" redirectPort="8443" />

?

?

?

?

?

?

?

?

?

?

?

? connectionTimeout - 網(wǎng)絡(luò)連接超時(shí),單位:毫秒。設(shè)置為0表示永不超時(shí),這樣設(shè)置有隱患的。通常可設(shè)置為30000毫秒。 keepAliveTimeout - 長(zhǎng)連接最大保持時(shí)間(毫秒)。此處為15秒。 maxKeepAliveRequests - 最大長(zhǎng)連接個(gè)數(shù)(1表示禁用,-1表示不限制個(gè)數(shù),默認(rèn)100個(gè)。一般設(shè)置在100~200之間) maxHttpHeaderSize - http請(qǐng)求頭信息的最大程度,超過此長(zhǎng)度的部分不予處理。一般8K 。 URIEncoding - 指定Tomcat 容器的URL 編碼格式。 acceptCount - 指定當(dāng)所有可以使用的處理請(qǐng)求的線程數(shù)都被使用時(shí),可以放到處理隊(duì)列中的請(qǐng)求數(shù),超過這個(gè)數(shù)的請(qǐng)求將不予處理,默認(rèn)為10個(gè)。 disableUploadTimeout - 上傳時(shí)是否使用超時(shí)機(jī)制 enableLookups - 是否反查域名,取值為:true 或false 。為了提高處理能力,應(yīng)設(shè)置為false bufferSize - defines the size (in bytes) of the buffer to be provided for input streams created by this connector. By default, buffers of 2048 bytes are provided. maxSpareThreads - 做多空閑連接數(shù),一旦創(chuàng)建的線程超過這個(gè)值,T omcat 就會(huì)關(guān)閉不再需要的socket 線程 maxThreads - 最多同時(shí)處理的連接數(shù),Tomcat 使用線程來處理接收的每個(gè)請(qǐng)求。這個(gè)值表示Tomcat 可創(chuàng)建的最大的線程數(shù)。。 minSpareThreads - 最小空閑線程數(shù),T omcat 初始化時(shí)創(chuàng)建的線程數(shù)

四、nginx 安裝與配置

解壓安裝nginx :

[root@admin local]# tar -zxvf nginx

[root@admin local]# make

[root@admin local]# make install

,

啟動(dòng):./nginx

停止:./nginx -s stop

重啟:./nginx -s reload

配置與參數(shù):

vi /usr/local/nginx/conf/nginx.conf

#定義Nginx 運(yùn)行的用戶和用戶組

user www www;

#nginx進(jìn)程數(shù),建議設(shè)置為等于CPU 總核心數(shù)。

worker_processes 8;

#全局錯(cuò)誤日志定義類型,[ debug | info | notice | warn | error | crit ] error_log ar/loginx/error.log info;

#進(jìn)程文件

pid ar/runinx.pid;

#一個(gè)nginx 進(jìn)程打開的最多文件描述符數(shù)目,理論值應(yīng)該是最多打開文件數(shù)(系統(tǒng)的值ulimit -n)與nginx 進(jìn)程數(shù)相除,但是nginx 分配請(qǐng)求并不均勻,所以建議與ulimit -n的值保持一致。

worker_rlimit_nofile 65535;

#工作模式與連接數(shù)上限

events

{

#參考事件模型,use [ kqueue | rtsig | epoll | /dev/poll | select | poll ]; epoll模型是Linux 2.6以上版本內(nèi)核中的高性能網(wǎng)絡(luò)I/O模型,如果跑在FreeBSD 上面,就用kqueue 模型。

use epoll;

#單個(gè)進(jìn)程最大連接數(shù)(最大連接數(shù)=連接數(shù)*進(jìn)程數(shù))

worker_connections 65535;

}

,

#設(shè)定http 服務(wù)器

{

include mime.types; #文件擴(kuò)展名與文件類型映射表

default_type application/octet-stream; #默認(rèn)文件類型

#charset utf-8; #默認(rèn)編碼

server_names_hash_bucket_size 128; #服務(wù)器名字的hash 表大小

client_header_buffer_size 32k; #上傳文件大小限制

large_client_header_buffers 4 64k; #設(shè)定請(qǐng)求緩

client_max_body_size 8m; #設(shè)定請(qǐng)求緩

sendfile on; #開啟高效文件傳輸模式,sendfile 指令指定nginx 是否調(diào)用sendfile 函數(shù)來輸出文件,對(duì)于普通應(yīng)用設(shè)為 on,如果用來進(jìn)行下載等應(yīng)用磁盤IO 重負(fù)載應(yīng)用,可設(shè)置為off ,以平衡磁盤與網(wǎng)絡(luò)I/O處理速度,降低系統(tǒng)的負(fù)載。注意:如果圖片顯示不正常把這個(gè)改成off 。

autoindex on; #開啟目錄列表訪問,合適下載服務(wù)器,默認(rèn)關(guān)閉。

tcp_nopush on; #防止網(wǎng)絡(luò)阻塞

tcp_nodelay on; #防止網(wǎng)絡(luò)阻塞

keepalive_timeout 120; #長(zhǎng)連接超時(shí)時(shí)間,單位是秒

#FastCGI相關(guān)參數(shù)是為了改善網(wǎng)站的性能:減少資源占用,提高訪問速度。下面參數(shù)看字面意思都能理解。

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffer_size 64k;

fastcgi_buffers 4 64k;

fastcgi_busy_buffers_size 128k;

fastcgi_temp_file_write_size 128k;

#gzip模塊設(shè)置

gzip on; #開啟gzip 壓縮輸出

gzip_min_length 1k; #最小壓縮文件大小

gzip_buffers 4 16k; #壓縮緩沖區(qū)

,

gzip_http_version 1.0; #壓縮版本(默認(rèn)1.1,前端如果是squid2.5請(qǐng)使用1.0) gzip_comp_level 2; #壓縮等級(jí)

gzip_types text/plain application/x-javascript text/css application/xml;

#壓縮類型,默認(rèn)就已經(jīng)包含textml ,所以下面就不用再寫了,寫上去也不會(huì)有問題,但是會(huì)有一個(gè)warn 。

gzip_vary on;

#limit_zone crawler $binary_remote_addr 10m; #開啟限制IP 連接數(shù)的時(shí)候需要使用

upstream blog.ha97.com {

#upstream的負(fù)載均衡,weight 是權(quán)重,可以根據(jù)機(jī)器配置定義權(quán)重。weigth 參數(shù)表示權(quán)值,權(quán)值越高被分配到的幾率越大。

server 192.168.80.121:80 weight=3;

server 192.168.80.122:80 weight=2;

server 192.168.80.123:80 weight=3;

}

#虛擬主機(jī)的配置

server {

listen 80;

server_name sso.bbaba.com;

charset utf-8;

proxy_set_header Host $host;

proxy_redirect off;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_connect_timeout 300;

proxy_read_timeout 300;

proxy_send_timeout 300;

rewrite ^/RedSSO/(.*)$ /$1 permanent;

#虛擬目錄

location / {

root /home/product/RedBase/RedSSO/;

index index.html index.htm index.jsp index.action;

proxy_pass http://localhost:6080/RedSSO/;

}

,

# 參數(shù)說明

#對(duì) "/" 啟用反向代理

location / {

proxy_pass http://127.0.0.1:88;

proxy_redirect off;

proxy_set_header X-Real-IP $remote_addr;

#后端的Web 服務(wù)器可以通過X-Forwarded-For 獲取用戶真實(shí)IP proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#以下是一些反向代理的配置,可選。

proxy_set_header Host $host;

client_max_body_size 10m; #允許客戶端請(qǐng)求的最大單文件字節(jié)數(shù)

client_body_buffer_size 128k; #緩沖區(qū)代理緩沖用戶端請(qǐng)求的最大字節(jié)數(shù), proxy_connect_timeout 90; #nginx跟后端服務(wù)器連接超時(shí)時(shí)間(代理連接超時(shí)) proxy_send_timeout 90; #后端服務(wù)器數(shù)據(jù)回傳時(shí)間(代理發(fā)送超時(shí))

proxy_read_timeout 90; #連接成功后,后端服務(wù)器響應(yīng)時(shí)間(代理接收超時(shí)) proxy_buffer_size 4k; #設(shè)置代理服務(wù)器(nginx )保存用戶頭信息的緩沖區(qū)大小 proxy_buffers 4 32k; #proxy_buffers緩沖區(qū),網(wǎng)頁平均在32k 以下的設(shè)置 proxy_busy_buffers_size 64k; #高負(fù)荷下緩沖大?。╬roxy_buffers*2) proxy_temp_file_write_size 64k;

#設(shè)定緩存文件夾大小,大于這個(gè)值,將從upstream 服務(wù)器傳

}

#圖片緩存時(shí)間設(shè)置

location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 10d;

}

#JS和CSS 緩存時(shí)間設(shè)置

location ~ .*.(js|css)?$

{

expires 1h;

}

,

#日志格式設(shè)定

log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" $http_x_forwarded_for';

#定義本虛擬主機(jī)的訪問日志

access_log ar/loginx/ha97access.log access;

#設(shè)定查看Nginx 狀態(tài)的地址

location /NginxStatus {

stub_status on;

access_log on;

auth_basic "NginxStatus";

auth_basic_user_file confpasswd;

#htpasswd文件的內(nèi)容可以用apache 提供的htpasswd 工具來產(chǎn)生。

}

#本地動(dòng)靜分離反向代理配置

#所有jsp 的頁面均交由tomcat 或resin 處理

location ~ .(jsp|jspx|do)?$ {

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://127.0.0.1:8080;

}

#所有靜態(tài)文件由nginx 直接讀取不經(jīng)過tomcat 或resin

location

~ .*.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$

{ expires 15d; }

location ~ .*.(js|css)?$

{ expires 1h; }

}

}

,

擴(kuò)展:配置開機(jī)啟動(dòng)

如果需要開機(jī)啟動(dòng)服務(wù),保存好 /etc/init.d/nginx文件后,執(zhí)行以下命令:

1

2

五、防火墻的基本配置

1) 永久性生效,重啟后不會(huì)復(fù)原

開啟: chkconfig iptables on

關(guān)閉: chkconfig iptables off

2) 即時(shí)生效,重啟后復(fù)原

開啟: service iptables start

關(guān)閉: service iptables stop

端口開啟:

vi /etc/sysconfig/iptables

#開啟80 和22 端口

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT [root@unique init.d]#chkconfig --add ningx [root@unique init.d]#chkconfig --level nginx 2345 on

標(biāo)簽: