Centos x64 6.2配置JSP環境
Centos x64 6.2配置JSP環境
1、最小化安裝伺服器
2、yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel cURL cURL-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel lsof
3、(1)下載完成jdk-7u17-linux-x64.tar.gz
(2)解壓tar zxvf jdk-7u17-linux-x64.tar.gz
(3)解壓後將其移動到mv jdk-7u17-linux-x64 /usr/local/jdk
(4)配置 vi /etc/profile 環境變數,增加以下內容:
JAVA_HOME="/usr/local/jdk"
CLASS_PATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib"
PATH=".:$PATH:$JAVA_HOME/bin"
CATALINA_HOME="/usr/local/tomcat"
export JAVA_HOME CATALINA_HOME
4、解壓apache-tomcat-7.0.37.tar.gz
]# mv apache-tomcat-7.0.37 /usr/local/tomcat
將tomcat相關配置複製到網站目錄中去
]# mkdir -p /webdata/htdocs/www/shop/ROOT
]# cp -Rf /usr/local/tomcat/webapps /webdata/htdocs/www (備註:此部暫不用操作)
編輯tomcat的server.xml
Vi /usr/local/tomcat/conf/server.xml
<Host name="localhost" appBase="/webdata/htdocs/www/shop/ROOT"
unpackWARs="true" autoDeploy="true">
(目錄中必須有ROOT,否則tomcat找不到)
啟動tomcat /usr/local/tomcat/bin/startup.sh
使用lsof –i :8080
測試服務是否啟動
[root@localhost bin]# lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 3065 root 40u IPv6 36361 0t0 TCP *:webcache (LISTEN)
5、安裝pcre,,通過 yum install pcre pcre-devel
6、安裝nginx
[root@localhost bin]# useradd www
[root@localhost bin]# mkdir -p /webdata/logs #日誌目錄
mkdir -p /webdata/htdocs/www/shop/ROOT #網頁目錄
[root@localhost bin]# chown -R www:www /webdata
開始配置nginx原始碼檔案
[root@localhost nginx-1.2.7]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
出錯:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
需要安裝pcre
下載新版pcre-8.32.tar.gz 解壓安裝
./configure
Make
Make install
繼續nginx
[root@localhost nginx-1.2.7]# ./configure --user=www --group=www --prefix=/usr/l
ocal/nginx --with-http_stub_status_module --with-http_ssl_module
Make
Make install
-------------------------------------------------------------------------------------------
安裝Nginx時報錯
./configure: error: the HTTP rewrite module requires the PCRE library.
安裝pcre-devel解決問題
yum -y install pcre-devel
錯誤提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解決辦法:
yum -y install openssl openssl-devel
總結:
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx
make
make install
7、配置nginx.conf 在/usr/local/tomcat/conf/nginx.conf
配置內容如下:
user www www;
worker_processes 1;
error_log /webdata/logs/error.log crit;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
server_tokens off;
client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_send_timeout 60;
proxy_read_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#access_log logs/host.access.log main;
log_format wwwlog '$remote_addr -$remote_user[$time_local]"$request"'
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent" $http_x_forwarded_for';
access_log /webdata/logs/web.log wwwlog;
server {
listen 80;
server_name localhost;
index index.html index.htm index.jsp index.do;
root /webdata/htdocs/www/shop/ROOT;
if ( -d $request_filename)
{
# rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break;
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
location ~ .*\.(jsp|jspx|do)?$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8080; #תÏòtomcat´¦Àí
}
#charset koi8-r;
location ~ .*\.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$ {
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
}
}
8、啟動nginx
/usr/local/nginx/sbin/nginx
檢視nginx
#ps –ef | grep nginx
這時,輸入以下命令檢視Nginx主程式號:
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
螢幕顯示的即為Nginx主程式號,例如:
6302
這時,執行以下命令即可使修改過的Nginx配置檔案生效:
kill -HUP 6302
或者無需這麼麻煩,找到Nginx的Pid檔案:
平滑重啟:
kill -HUP `cat /usr/local/nginx/nginx.pid`
或者lsof –i:80
9、停止nginx的命令
#/usr/local/nginx/sbin/nginx -s stop
1、最小化安裝伺服器
2、yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel cURL cURL-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel lsof
3、(1)下載完成jdk-7u17-linux-x64.tar.gz
(2)解壓tar zxvf jdk-7u17-linux-x64.tar.gz
(3)解壓後將其移動到mv jdk-7u17-linux-x64 /usr/local/jdk
(4)配置 vi /etc/profile 環境變數,增加以下內容:
JAVA_HOME="/usr/local/jdk"
CLASS_PATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib"
PATH=".:$PATH:$JAVA_HOME/bin"
CATALINA_HOME="/usr/local/tomcat"
export JAVA_HOME CATALINA_HOME
4、解壓apache-tomcat-7.0.37.tar.gz
]# mv apache-tomcat-7.0.37 /usr/local/tomcat
將tomcat相關配置複製到網站目錄中去
]# mkdir -p /webdata/htdocs/www/shop/ROOT
]# cp -Rf /usr/local/tomcat/webapps /webdata/htdocs/www (備註:此部暫不用操作)
編輯tomcat的server.xml
Vi /usr/local/tomcat/conf/server.xml
<Host name="localhost" appBase="/webdata/htdocs/www/shop/ROOT"
unpackWARs="true" autoDeploy="true">
(目錄中必須有ROOT,否則tomcat找不到)
啟動tomcat /usr/local/tomcat/bin/startup.sh
使用lsof –i :8080
測試服務是否啟動
[root@localhost bin]# lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 3065 root 40u IPv6 36361 0t0 TCP *:webcache (LISTEN)
5、安裝pcre,,通過 yum install pcre pcre-devel
6、安裝nginx
[root@localhost bin]# useradd www
[root@localhost bin]# mkdir -p /webdata/logs #日誌目錄
mkdir -p /webdata/htdocs/www/shop/ROOT #網頁目錄
[root@localhost bin]# chown -R www:www /webdata
開始配置nginx原始碼檔案
[root@localhost nginx-1.2.7]# ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
出錯:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
需要安裝pcre
下載新版pcre-8.32.tar.gz 解壓安裝
./configure
Make
Make install
繼續nginx
[root@localhost nginx-1.2.7]# ./configure --user=www --group=www --prefix=/usr/l
ocal/nginx --with-http_stub_status_module --with-http_ssl_module
Make
Make install
-------------------------------------------------------------------------------------------
安裝Nginx時報錯
./configure: error: the HTTP rewrite module requires the PCRE library.
安裝pcre-devel解決問題
yum -y install pcre-devel
錯誤提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解決辦法:
yum -y install openssl openssl-devel
總結:
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx
make
make install
7、配置nginx.conf 在/usr/local/tomcat/conf/nginx.conf
配置內容如下:
user www www;
worker_processes 1;
error_log /webdata/logs/error.log crit;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
server_tokens off;
client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_send_timeout 60;
proxy_read_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#access_log logs/host.access.log main;
log_format wwwlog '$remote_addr -$remote_user[$time_local]"$request"'
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent" $http_x_forwarded_for';
access_log /webdata/logs/web.log wwwlog;
server {
listen 80;
server_name localhost;
index index.html index.htm index.jsp index.do;
root /webdata/htdocs/www/shop/ROOT;
if ( -d $request_filename)
{
# rewrite ^(/download/.*)/media/(.*)\..*$ $1/mp3/$2.mp3 break;
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
location ~ .*\.(jsp|jspx|do)?$ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8080; #תÏòtomcat´¦Àí
}
#charset koi8-r;
location ~ .*\.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma)$ {
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
}
}
8、啟動nginx
/usr/local/nginx/sbin/nginx
檢視nginx
#ps –ef | grep nginx
這時,輸入以下命令檢視Nginx主程式號:
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'
螢幕顯示的即為Nginx主程式號,例如:
6302
這時,執行以下命令即可使修改過的Nginx配置檔案生效:
kill -HUP 6302
或者無需這麼麻煩,找到Nginx的Pid檔案:
平滑重啟:
kill -HUP `cat /usr/local/nginx/nginx.pid`
或者lsof –i:80
9、停止nginx的命令
#/usr/local/nginx/sbin/nginx -s stop
本文轉自 lcpljc 51CTO部落格,原文連結:http://blog.51cto.com/lcpljc/1170928,如需轉載請自行聯絡原作者
相關文章
- centos6.2LNMP環境安裝(yum)CentOSLNMP
- CentOS 配置 PHP 環境CentOSPHP
- JAVA 環境配置 CentOSJavaCentOS
- CentOS python環境配置CentOSPython
- CentOS7 環境配置指南CentOS
- centos6.2lnmp環境下安裝zabbix(中文環境)並且監控客戶端CentOSLNMP客戶端
- centos下配置java環境變數CentOSJava變數
- 新手入門經典:Jsp環境配置JS
- Unix環境中配置JSP的方法(轉)JS
- Linux下jsp環境:apache,tomcat配置LinuxJSApacheTomcat
- centos配置vim c++開發環境CentOSC++開發環境
- CentOS上JETTY環境的配置安裝CentOSJetty
- zerorunner 在 Centos 的環境配置和部署CentOS
- Tomcat下JSP、Servlet和JavaBean環境的配置TomcatJSServletJavaBean
- CentOS7 配置 LNMP 伺服器環境CentOSLNMP伺服器
- CentOS SVN 環境搭建配置跟自動部署CentOS
- CentOS 6.4 x64 安裝 配置 Redmine 2.4.1CentOS
- Centos6.2中mysql的安裝與配置CentOSMySql
- CentOS環境下LAMP開發環境的搭建與配置(10分鐘搞定!!!)CentOSLAMP開發環境
- Java初學者:Jsp開發環境配置全過程JavaJS開發環境
- Linux-CentOS7環境MySQL安裝配置LinuxCentOSMySql
- Centos7配置webrtc-streamer環境教程。CentOSWeb
- CentOS 6.x 上配置Apache+PHP環境CentOSApachePHP
- JSP的環境引擎--websphereJSWeb
- 關於開發jsp標籤的環境配置問題JS
- Vagrant 搭建 CentOS 環境CentOS
- centos 前端環境搭建CentOS前端
- centos搭建virtualenv環境CentOS
- app自動化測試環境配置:adb環境配置、monkey環境配置、appium環境配置大全APP
- Centos7下配置PHP + MySQL + Nginx開發環境CentOSPHPMySqlNginx開發環境
- Docker 實戰之 CentOS7 系統環境配置DockerCentOS
- 基於CentOS 7.6安裝及配置APISIX 3.0環境CentOSAPI
- vmware中安裝centos6.5配置網路環境CentOS
- centos下部署redis服務環境及其配置說明CentOSRedis
- 環境配置
- win98下配置jsp的執行環境實踐 (轉)JS
- 配置開發環境、生成環境、測試環境開發環境
- KVM 虛擬機器安裝配置在CentOS6.2虛擬機CentOS