首頁 >Java >java教程 >雲端伺服器中部署java web的方法

雲端伺服器中部署java web的方法

巴扎黑
巴扎黑原創
2017-07-17 16:16:061921瀏覽

一、準備工作 

1、註冊帳號

#下載完成後。可到這裡  申請1GB雲端伺服器ECS的15天的免費試用,以及雲端資料庫RDS 5G 30天的免費試用。

2、下載putty和FileZlilla

本地遠端SSH登陸到個人阿里雲端伺服器的過程很簡單,這裡就不再細說 

#二、JDK安裝 

1、先到下載JDK,下載到本到後,透過FileZlilla上傳此壓縮封包到個人雲端伺服器

開啟putty。輸入IP位址,依照指示輸入使用者名稱和密碼即可。 (密碼為你登陸阿里雲首頁的那個密碼)

(tomcat是下一步下面要安裝到的)

好了,之後就很簡單了。

 

2、設定目錄

注意:最好以root使用者來操作

先新建一個目錄:

 

[plain] view plain copy
 
  1. ##cd usr  

##mkdir java  

cd java  

mkdir jdk  

mkdir jdk  

## 然後解壓縮jdk的tar檔案到上面的目錄:
 
  1. [plain]

     view plain copy
  2.  

tar zxvf jdk-8u73-linux-x64.gz -C /usr/java/jdk   

  1. #1

  2. 結果如下:

 

 

##3、設定環境變數

#輸入:
 
[plain]
 view plain copy
 
vi /etc/profile  
############# ######或###### ##################################################################### ##[plain]### view plain copy### ###################gedit   /etc/profile  ###################### ## ######加入以下內容:###### ################[plain]### view plain copy### ##### ##############set java environment  ############export JAVA_HOME=/usr/java/jdk/jdk1.8.0_73  ########################################################################################################12 #####export JRE_HOME=/usr/java/jdk/jdk1.8.0_73/jre  ############export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH ############export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$JAVA_HOME:$PATH  ################注意這裡改成對應的jdk的目錄,並且要以root使用者來做修改,否則無法儲存###### #######儲存後執行:###### ########## #####[plain]### view plain copy### ###################source /etc/profile  ########################################################## #####驗證安裝:###### ######輸入:###### ##############[plain]### view plain copy### ##################java -version  ############


The following appears, indicating that the installation is successful

3. Configure tomcat

1. Download tomcat, go to download, here the author uses It is tomcat7. At the same time, download tomcat to the local computer and upload the compressed package to the personal cloud server through FileZlilla.

This is after the upload is successful:

2. Installation

Here I install tomcat into /usr/java/tomcat.

Execute

[plain] view plain copy
  1. tar zxvf apache-tomcat-7.0.68.tar.gz -C /usr/java/tomcat

  2. ##

    Pay attention to the tomcat directory in advance Created

3. Configure the environment

Enter the bin folder of tomcat above:

##Open

[plain]
view plain copy
    vi setclasspath.sh
or

[plain]
view plain copy
##gedit setclasspath.sh
  1. Add the following content:

##[plain]
view plain copy
export JAVA_HOME=/usr/java/jdk/jdk1.8.0_65
  1. export JRE_HOME=/usr/java/jdk/jdk1.8.0_65/jre

Save it.

Then return to the bin directory:

Execute:

[plain ]
view plain copy
./startup.sh
  1. appears as follows , indicating that the installation is successful

Or directly access externally through the port, first check the external IP of your server

After confirmation, add port 8080 to access:

4. Upload java web from local Project

1. War package upload

This is a locally packaged war package.

Here I directly use the previously packaged war package war package, open FileZilla, and then select

. Note that the personal cloud server must choose the correct address, otherwise you have to cp here. Remember to put the war package under webapps under tomcat

2, then open the browser and enter

http://120.24.19.24:8080 /JavaHelloWorld-0.0.1-SNAPSHOT/

Found that it can be accessed!

Of course, you can also go to the cloud server to view the war package:

Instance access to this article: http:// 120.24.19.24:8080/JavaHelloWorld-0.0.1-SNAPSHOT/ (will no longer be accessible until 2016.3.9)

以上是雲端伺服器中部署java web的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn