一、準備工作
1、註冊帳號
#下載完成後。可到這裡 申請1GB雲端伺服器ECS的15天的免費試用,以及雲端資料庫RDS 5G 30天的免費試用。
![](https://img.php.cn/upload/article/000/000/001/80d4749e1d00a1846b2f5013553cc8bd-0.png)
2、下載putty和FileZlilla
本地遠端SSH登陸到個人阿里雲端伺服器的過程很簡單,這裡就不再細說
![](https://img.php.cn/upload/article/000/000/001/80d4749e1d00a1846b2f5013553cc8bd-1.png)
#二、JDK安裝
1、先到下載JDK,下載到本到後,透過FileZlilla上傳此壓縮封包到個人雲端伺服器
![](https://img.php.cn/upload/article/000/000/001/739592e449cb89fb6c5501d25747c1ac-2.png)
開啟putty。輸入IP位址,依照指示輸入使用者名稱和密碼即可。 (密碼為你登陸阿里雲首頁的那個密碼)
![](https://img.php.cn/upload/article/000/000/001/739592e449cb89fb6c5501d25747c1ac-3.png)
(tomcat是下一步下面要安裝到的)
好了,之後就很簡單了。
2、設定目錄
注意:最好以root使用者來操作
先新建一個目錄:
##mkdir java
cd java
mkdir jdk
mkdir jdk
tar zxvf jdk-8u73-linux-x64.gz -C /usr/java/jdk
##3、設定環境變數
#輸入:
############# ######或###### ##################################################################### ##[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
![](https://img.php.cn/upload/article/000/000/001/6cc6cbda3d7e77f7868c497fe511dff6-5.png)
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.
![](https://img.php.cn/upload/article/000/000/001/6cc6cbda3d7e77f7868c497fe511dff6-6.png)
This is after the upload is successful:
![](https://img.php.cn/upload/article/000/000/001/6cc6cbda3d7e77f7868c497fe511dff6-7.png)
2. Installation
Here I install tomcat into /usr/java/tomcat.
Execute
tar zxvf apache-tomcat-7.0.68.tar.gz -C /usr/java/tomcat
- ##
Pay attention to the tomcat directory in advance Created
-
3. Configure the environment
Enter the bin folder of tomcat above:
##Open
##gedit setclasspath.sh
Add the following content:
##[plain]
view plain copy
export JAVA_HOME=/usr/java/jdk/jdk1.8.0_65
export JRE_HOME=/usr/java/jdk/jdk1.8.0_65/jre
-
Save it.
Then return to the bin directory:
Execute:
[plain ]
view plain copy
-
appears as follows , indicating that the installation is successful
![](https://img.php.cn/upload/article/000/000/001/7ac3cd45858a3bee12905b6b2d9fec4d-10.png)
Or directly access externally through the port, first check the external IP of your server
After confirmation, add port 8080 to access:
![](https://img.php.cn/upload/article/000/000/001/7ac3cd45858a3bee12905b6b2d9fec4d-11.png)
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:
![](https://img.php.cn/upload/article/000/000/001/9ad04cf6f6405cd33fd336765793694b-15.png)
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中文網其他相關文章!