码迷,mamicode.com
首页 > 数据库 > 详细

Vagrant搭建Ubuntu-JavaEE开发环境——Tomcat+JDK+MySql+dubbo+测试

时间:2016-05-08 14:58:54      阅读:835      评论:0      收藏:0      [点我收藏+]

标签:

Vagrant搭建(Tomcat8+JDK7+MySQL5+dubbo)

JDK

1.下载jdk

2.解压JDK

tar -xzvf jdk-7u79-linux-x64.tar.gz 

3.设置环境变量

vim /home/vagrant/.bashrc

  这里因为我用的vagrant所以提示:   

The program ‘vim‘ can be found in the following packages:
* vim
* vim-gnome
* vim-tiny
* vim-athena
* vim-gtk
* vim-nox Try: sudo apt-get install
<selected package>

 

  所以要先下载vim:

sudo apt-get install vim

  如果继续报错,或者根据URL连接不上:  

sudo apt-get update
sudo apt-get install vim

  最后再次尝试:

vim /home/vagrant/.bashrc

  进入vim编辑页面,control或ctrl + d向下翻页,至文件底部,键盘输入i进入编辑模式,将以下添加上:

 JAVA_HOME=/home/vagrant/soft/jdk1.8.0_25
 PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin
 export JAVA_HOME
 export PATH

  刷新配置文件,重新载入

source ~/.bashrc

  验证是否安装成功

vagrant@precise64:~/soft/jdk1.7.0_79$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

 

Tomcat

1.下载Tomcat

2.解压Tomcat

tar -xzvf apache-tomcat-8.0.15.tar.gz

3.配置环境变量

vim /home/vagrant/.bashrc

  在文件尾部追加

 CATALINA_HOME=/home/vagrant/soft/apache-tomcat-8.0.15
 export CATALINA_HOME

  保存文件,重载配置文件

source ~/.bashrc

  验证是否安装成功

vagrant@precise64:~/soft/Tomcat8.0.28$ sh ./bin/startup.sh 
Using CATALINA_BASE:   /home/vagrant/soft/Tomcat8.0.28
Using CATALINA_HOME:   /home/vagrant/soft/Tomcat8.0.28
Using CATALINA_TMPDIR: /home/vagrant/soft/Tomcat8.0.28/temp
Using JRE_HOME:        /home/vagrant/soft/jdk1.7.0_79
Using CLASSPATH:       /home/vagrant/soft/Tomcat8.0.28/bin/bootstrap.jar:/home/vagrant/soft/Tomcat8.0.28/bin/tomcat-juli.jar
Tomcat started.

4.打开浏览器

  如果是在主机上,没问题,现在已经能打开了,但如果用vagrant搭建的虚拟机,那么还需要以下操作:

  编辑Vagrantfile文件:

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
   config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
   config.vm.network "private_network", ip: "192.168.33.10"

  其中“forwarded_port”表示将虚拟机的80端口映射至主机的8080端口,也就是说,如果虚拟机的Tomcat端口默认为8080,那么在主机浏览器访问虚拟机IP(“private_network”设置):8080即可访问到Tomcat webapp

  设置后,重启虚拟机:

vagrant reload

 

Vagrant搭建Ubuntu-JavaEE开发环境——Tomcat+JDK+MySql+dubbo+测试

标签:

原文地址:http://www.cnblogs.com/zhengbin/p/5470539.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!