linux下部署一個JavaEE項目的簡單步驟

來源:互聯網
上載者:User

標籤:war包   伺服器   檔案   sql資料庫   his   top   lan   local   建立資料庫   

 部署項目的前提是準備好環境,包括:Java運行環境(JDK),Tomcat,Mysql資料庫

1.首先將東西上傳到伺服器,我是在windows安裝ssh工具(下載安裝git即可http://gitforwindows.org/)

(1)windows下將項目導成war包,匯出資料庫指令碼

  匯出之後將war包的資料庫db.properties改為linux伺服器上的串連資訊

(2)將war包與指令碼上傳到伺服器

liqiang@root MINGW64 ~$ scp /c/Users/liqiang/Desktop/Exam.war root@qiaoliqiang.cn:/home$ scp /c/Users/liqiang/Desktop/exam.sql root@qiaoliqiang.cn:/home

 

(3)運行sql指令碼,建立資料庫並匯入sql指令碼:

  1. 查看從windows傳的檔案
$ ssh root@qiaoliqiang.cnLast login: Fri Jan 19 11:26:28 2018 from 218.26.54.83Welcome to Alibaba Cloud Elastic Compute Service ![[email protected] ~]# ls /home/exam.sql  Exam.war  test.html[[email protected] ~]#

 

  2.匯入mysql 指令檔

mysql> create database exam;mysql> use exam;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> source /home/exam.sql

 

 

 2.將war包放到tomcat安裝目錄的webapps目錄:(或者手動從tomcat的manager部署項目)

(1)如果是之前沒有此項目可以直接將war包放進去,tomcat會掃描

[[email protected] ~]# cp /home/Exam.war /usr/local/apache-tomcat-7.0.72/webapps/

 

 

 (2)如果之前有此項目需要停掉服務,將原來的war包及目錄刪掉之後重新啟動項目

[[email protected] ~]# service tomcat stop[[email protected] ~]# cd /usr/local/apache-tomcat-7.0.72/webapps/[[email protected] ~]# rm Exam -rf[[email protected] ~]# rm Exam.war[[email protected] ~]# cp /home/Exam.war /usr/local/apache-tomcat-7.0.72/webapps/[[email protected] ~]#service tomcat start

 

刪除目錄後面加上 -rf 

 

 3.測試專案部署:

curl localhost:88080

 

linux下部署一個JavaEE項目的簡單步驟

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.