寫在前面(建議)安裝XShell,編寫指令很是方便,能夠拷貝 安裝FTP,傳輸文件很是方便 設置vim,顯示行號sudo vim /etc/vim/vimrc,添加set number便可
![](http://static.javashuo.com/static/loading.gif)
安裝JDK 方法1:
一、查看jdk版本
apt-cache search openjdk
二、找到合適的版本後安裝:
sudo apt-get install openjdk-7-jdk
方法2:
一、官網下載jdk,解壓壓縮文件(tar.gz結尾)
![](http://static.javashuo.com/static/loading.gif)
解壓以後
shift+g跳至文件末尾,e變爲編輯狀態,添加以下信息:
![](http://static.javashuo.com/static/loading.gif)
二、更改$(普通用戶)爲#(超級用戶)權限
su root---->輸入密碼
進入超級用戶目錄下
三、打開~/.bashrc文件
![](http://static.javashuo.com/static/loading.gif)
三、打開~/.bashrc文件
![](http://static.javashuo.com/static/loading.gif)
export JAVA_HOME=/home/ubuntu/jdk1.8.0_101 export JAVA_BIN=$JAVA_HOME/bin export JAVA_LIB=$JAVA_HOME/lib export CLASSPATH=.:$JAVA_LIB/tools.jar:$JAVA_LIB/dt.jar export PATH=$JAVA_BIN:$PATH
![](http://static.javashuo.com/static/loading.gif)
:wq保存退出(PS::q!爲不保存退出)
四、執行source ~/.bashrc 命令,使jdk環境變量生效,而後查看jdk版本信息看是否安裝成功
![](http://static.javashuo.com/static/loading.gif)
五、建立一個測試文件test.java,看是否能夠用
![](http://static.javashuo.com/static/loading.gif)
也可使用touch命令,建立一個文件。
編輯test.java內容,以下:
![](http://static.javashuo.com/static/loading.gif)
執行結果:
![](http://static.javashuo.com/static/loading.gif)
說明jdk已經成功配置並可正常工做。
安裝Tomcat
tomcat官網下載了8.5.4版本的tar.gz壓縮文件,而後將文件傳輸至linux下
tomcat下載地址:http://tomcat.apache.org/download-80.cgi
一、解壓tomcat壓縮文件
二、修改catalina.sh文件(目錄爲:apache-tomcat-8.5.4/bin下)
![](http://static.javashuo.com/static/loading.gif)
二、修改catalina.sh文件(目錄爲:apache-tomcat-8.5.4/bin下)
![](http://static.javashuo.com/static/loading.gif)
在最後添加語句並保存,以下:
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true"
三、啓動tomcat服務器
![](http://static.javashuo.com/static/loading.gif)
四、打開瀏覽器,訪問網站,出現如下頁面則爲配置成功
![](http://static.javashuo.com/static/loading.gif)
Mysql配置
一、檢查是否已安裝,以下爲未安裝
![](http://static.javashuo.com/static/loading.gif)
二、安裝mysql
方式1:下載mysql,並傳輸至linux下,並解壓
下載地址:http://dev.mysql.com/downloads/mysql/#downloads--->選擇Linux Generic選擇版本下載
下載地址:http://dev.mysql.com/downloads/mysql/#downloads--->選擇Linux Generic選擇版本下載
![](http://static.javashuo.com/static/loading.gif)
參考網站:http://blog.sina.com.cn/s/blog_6702041f0100o4xn.html
方式2:在線安裝(本人選擇該方法,簡單)
先查看mysql版本信息
![](http://static.javashuo.com/static/loading.gif)
選擇須要安裝的版本安裝(必定要記住輸入的密碼)
![](http://static.javashuo.com/static/loading.gif)
三、再次測試,則已安裝完成
![](http://static.javashuo.com/static/loading.gif)
四、鏈接mysql數據庫
![](http://static.javashuo.com/static/loading.gif)
五、mysql經常使用命令
關機命令:service mysql stop
開機命令:service mysql start
使用netstat -an | grep 3306 命令查看3306端口
![](http://static.javashuo.com/static/loading.gif)
開機命令:service mysql start
![](http://static.javashuo.com/static/loading.gif)
重啓mysql:service mysql restart
退出mysql:exit / quit
建數據庫:create database 數據庫名;
查看數據庫:show databases;
刪除數據庫:drop database 數據庫名;
六、windows下鏈接linux的mysql數據庫
一、查看mysql默認端口3306是否對外開放
使用sudo netstat -lntp 命令查看全部tcp端口信息
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
發現127.0.0.1,那麼說明3306端口沒有對外開放,只是監聽本地的鏈接
二、若0.0.0.0的端口號不是3306,則打開/etc/mysql/my.cnf,註釋下圖所示行或者改爲你想要使用的客戶端主機Ip
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
三、將root用戶受權給因此鏈接
grant all privileges on *.* to 'root'@'%' identified by 'xxxxxx';// 'xxxxxx'爲mysql密碼
讓權限當即生效:flush privileges;
![](http://static.javashuo.com/static/loading.gif)
讓權限當即生效:flush privileges;
![](http://static.javashuo.com/static/loading.gif)
四、重啓mysql服務
sudo /etc/init.d/mysql restart
![](http://static.javashuo.com/static/loading.gif)
再次嘗試,navicat正常鏈接。
Maven web項目部署到linux
一、將項目打包成war
run as---->maven build---->配置以下:
![](http://static.javashuo.com/static/loading.gif)
二、將war包放至tomcat的webapps文件夾下
運行以後在target目錄下找到打包好的war文件,由於權限不足,不能直接傳輸至webapps文件下,因此將其傳輸至linux的/home/zd目錄下,而後剪切至webapps文件夾下
剪切命令:mv 文件名 路徑
![](http://static.javashuo.com/static/loading.gif)
因爲此時tomcat是啓動的,因此war包自動解壓
若未啓動tomcat,則啓動tomcat:(tomcat/bin下 ./startup.sh)
windows下訪問,以下:
![](http://static.javashuo.com/static/loading.gif)
你可能會遇到的問題:
xftp4不能上傳文件解決方案:
一、查看本身是否開啓了防火牆 (本人是暫時未開啓防火牆)
若開啓了防火牆:
方法1:關閉防火牆,sudo ufw disable
方法2:修改/etc/sysconfig/iptables,容許2一、20端口
xftp端口是21,數據端口是20,緣由詳見:http://blog.csdn.net/hzqhbc/article/details/12842145
開啓防火牆:sudo ufw enable
查看防火牆狀態:sudo ufw status
![](http://static.javashuo.com/static/loading.gif)
查看防火牆狀態:sudo ufw status
![](http://static.javashuo.com/static/loading.gif)
二、修改文件夾權限
先查看文件夾權限,在當前目錄ls -ld能夠查看,以下
![](http://static.javashuo.com/static/loading.gif)
zd爲新建文件夾。
參數意義:
第一列:「drwxr-x---」表識文件的類型和文件權限,其意義詳見這裏
第二列:「2」是純數字,表示文件連接個數
第三列:「root」表示文件的全部者
第四列:「root」表示爲文件的所在羣組
第五列:「4096」,表示爲文件長度(大小)
第六列:表示文件最後更新(修改)時間
第七列:表示文件的路徑
修改zd文件夾的權限:chmod 文件權限 文件名稱
權限更改完成,xftp4能夠正常上傳文件了。
![](http://static.javashuo.com/static/loading.gif)