CentOS 5.5 Nginx+JDK+MySQL+Tomcat(jsp)成功安装案例[服务器安全]
本文“CentOS 5.5 Nginx+JDK+MySQL+Tomcat(jsp)成功安装案例[服务器安全]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
在Centos 5.5中安装Nginx+jdk+mysql+tomcat是非常简单的.只需yum安装环境包和nginx、解压安装jdk和tomcat、配置profile文件、server.xml和nginx.conf文件便可.具体步骤以下
1、安装环境包
1、首先利用yum号令安装、进级所需的程序库.
yum -y 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-server krb5-devel libidn libidn-devel openldap
openldap-devel nss_ldap openldap-clients openldap-servers
2、yum安装mysql
先查抄mysql能否安装:
rpm -qa | grep mysql
假如没有安装齐备履行下列yum
yum install mysql-bench mysql-test mysql-devel mysql-server mysql
3、yum安装prce
先查抄prce能否安装:
rpm -qa | grep prce
假如没有安装履行下列yum
Yum install prce
2、yum安装nginx
1、安装nginx的最新安定版yum源
Nginx最新版yum源在EPEL RPM包中,wget下载安装便可
cd /root
wget http://download.Fedora.RedHat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm –ivh epel-release-5-4.noarch.rpm
2、安装nginx
Yum install nginx
3、启动测试nginx
Service nginx restart
Nginx启动后有两个进程,master为主进程,worker为工作进程
在启动完NGINX后,我们可以在浏览器中输入http://localhost查看welcome to nginx即算成功.
三.安装jdk
1、首先下载jdk,并安装jdk.
#cd /root
#wget http://cds-esd.sun.com/ESD6/JSCDL/jdk/6u23-b05/jdk-6u23-linux-i586.bin?AuthParam=1292548492_5c40501ebcb0ead52c24198a34e7e6ee&TicketId=B%
2Fw3nB2ESl1MSxRGMlFYlQHl&GroupName=CDS&FilePath=/ESD6/JSCDL/jdk/6u23-b05/jdk-6u23-linux-i586.bin&File=jdk-6u23-linux-i586.bin
下载完后,改正jdk-6u23-linux-i586.bin的文件属性为可履行,www.linuxidc.com然后履行该程序安装
#chmod +x jdk-6u23-linux-i586.bin
#cd ./ jdk-6u23-linux-i586.bin
#mv jdk1.6.0_23 /usr/local/jdk
2、编辑profile文件 设置开机文件java开机履行环境文件
#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
保存并退出vi,履行以下号令使配置见效,且重启电脑
#source /etc/profile
#reboot4、安装apache tomcat
1、下载apache tomcat并安装tomcat
#cd /root
#mkdir /www //成立网页根目录
#cp /usr/share/nginx/html/* /www/
#wget http://apache.etoak.com/tomcat/tomcat-7/v7.0.5-beta/bin/apache-tomcat-7.0.5.tar.gz
#tar zxvf apache-tomcat-7.0.5.tar.gz
#mv apache-tomcat-7.0.5 /usr/local/tomcat
#cp –rf /usr/local/tomcat/webapps/* /www/
2、配置tomcat的server.xml文件,并启动或终止tomcat
#vim /usr/local/tomcat/conf/server.xml
查找appBase=”webapps”,改正成appBase=”/www”,此中/www 即为网页的根目录.
安装完成后,启动tomcat,默许监听端口为8080
#/usr/local/tomcat/bin/startup.sh
终止tomcat可以利用以下号令:
#/usr/local/tomcat/bin/shutdown.sh
5、nginx与tomcat整合
Nginx与tomcat的整合其实就是只要配置好nginx.conf文件便可以了.
#vim /etc/nginx/nginx.conf //配置好的nginx.conf文件以下(注意红色部份)
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 65535;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
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 /var/log/nginx/access.log main;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32K;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
#tomcat add start<<
tcp_nodelay on;
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;
#tomcat add end>>
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 add start<<
upstream tomcat_server {
server 127.0.0.1:8080;
}
#tomcat add end>>
server {
listen 80;
server_name _;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /www;
index index.html index.htm index.jsp default.jsp index.do default.do;
}
#tomcat add start<<
以上是“CentOS 5.5 Nginx+JDK+MySQL+Tomcat(jsp)成功安装案例[服务器安全]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |