搭建java环境
搭建java环境
蓝蝶飞扬 发表于4年前
搭建java环境
  • 发表于 4年前
  • 阅读 113
  • 收藏 6
  • 点赞 0
  • 评论 0

移动开发云端新模式探索实践 >>>   

一.tomacat

Tomcat的安装分为两个步骤:安装JDK;安装Tomcat。 

JDK(JavaDevelopmentKit)是SunMicrosystems针对Java开发员的产品。自从Java推出以来, 

JDK已经成为使用最广泛的JavaSDK。JDK 是整个Java的核心,包括了Java运行环境,Java 

工具和Java基础的类库。所以要想运行jsp的程序必须要有JDK的支持,理所当然安装Tomcat 

的前提是安装好JDK。

1.安装JDK

shell>rpm -ivh jdk-7u51-linux-x64.rpm 

2.解压

shell>tar xvf apache-tomcat-7.0.52.tar.gz 

##移动文件

shell> mv apache-tomcat-7.0.52 /usr/local/tomcat

3.给tomcat添加JAVA主目录 

shell> vim /usr/local/tomcat/bin/catalina.sh  --96行

==============================

JAVA_HOME=/usr/java/jdk1.7.0_51

CATALINA_HOME=/usr/local/tomcat

==============================

4.做启动脚本

shell> cp /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat

shell> chmod +x /etc/init.d/tomcat 

shell>/etc/init.d/tomcat start

5.移动文件到指定目录并解压

shell>mv /softs/house_dazhima.zip /usr/local/tomcat/webapps

shell>cd /usr/local/tomcat/webapps

shell>unzip house_dazhima.zip 

6.修改相关配置

shell>vim /usr/local/tomcat/webapps/house_dazhima/WEB-INF/applicationContext.xml

=======================================================

<!-- 指定连接的数据库驱动 -->

        <property name="driverClass" value="com.mysql.jdbc.Driver" />

        <property name="jdbcUrl" value="jdbc:mysql://10.10.54.54:3306/housedb" />

        <!-- 指定连接数据库的用户名 -->

        <property name="user" value="house" />

        <property name="password" value="123456" />

======================================================

shell>/etc/init.d/tomcat stop

shell>/etc/init.d/tomcat start

二.mysql

1.安装mysql

shell>yum install mysql.x86_64 mysql-server.x86_64 

shell>/etc/init.d/mysql restart 

2.导入数据库并授权

shell>mysql -uroot -p</softs/housedb.sql

mysql>grant all on housedb.* to 'house'@'10.10.54.54' identified by '123456';

mysql>flush privileges;

3.验证

shell>mysql -u house -p -h10.10.54.54

三.测试

输入:

http://10.10.54.54:8080显示tomcat页面

http://10.10.54.54:8080/house_dazhima显示大芝麻首页

四.nginx

1.安装nginx

shell>tar xvf nginx-1.4.5.tar.gz 

shell>./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module

shell>make 

shell>make install

2.修改配置文件

shell>vim /usr/local/nginx/conf/nginx.conf

=========================================

user  nginx nginx;

worker_processes  2;

error_log  logs/error.log;

pid        logs/nginx.pid;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    access_log  logs/access.log;

    sendfile        on;

    tcp_nopush     on;

    keepalive_timeout  65;


    gzip  on;

    include virtual/house.ssr.com.conf;

}

==========================================

shell>mkdir /usr/local/nginx/conf/virtual

shell>cd /usr/local/nginx/conf/virtual

shell>vim house.ssr.com.conf

==========================================

upstream house.ssr.com {

   server 10.10.54.54:8080 max_fails=3 weight=1 fail_timeout=60s;

 }

server{

  listen  80;

  server_name  house.ssr.com;

  charset  utf-8;

  access_log  logs/www.access.log;

 location / {

  root /usr/local/tomcat/webapps/;

  proxy_pass http://house.ssr.com/house_dazhima/;

  index index.html index.htm index.jsp index.php;

 }


 location ~(\.jsp)|(\.do)$ {

        index index.jsp;

        proxy_pass http://house.ssr.com;

        proxy_set_header HOST $host;

        proxy_set_header X-Real_IP $remote_addr;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }

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

   expires      30d;

        }

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

 expires  1h;

 }

 }

=================================================

shell>/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf --启动

shell> cat /usr/local/nginx/logs/nginx.pid | xargs kill -HUP     --重启

3.添加DNS记录

shell>vim /var/named/named.ssr.com

===============================

10.10.54.54 house.ssr.com

===============================

shell>/etc/init.d/named restart

4.测试

输入:

http://house.ssr.com


标签: jdk tomcat dns
  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 24
博文 119
码字总数 89785
×
蓝蝶飞扬
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: