環(huán)境搭建: jdk1.8工窍,git氧吐,maven,tomcat8
工具安裝路徑:
java : /usr/local/jdk1.8
maven : /usr/local/apache-maven-3.6.2
git : /usr/local/git
tomcat: /usr/local/apache-tomcat-8.5.46
1启上,開啟ssh
[root@VM_0_6_centos ~]# netstat -anp|grep :22
tcp 0 0 0.0.0.0:22 0.0.0.0:*
tcp 0 36 172.16.0.6:22 211.161.248.60:22447
[root@VM_0_6_centos ~]# service sshd start
Redirecting to /bin/systemctl start sshd.service
2碍侦,關(guān)閉防火墻(內(nèi)網(wǎng)環(huán)境相對安全)
安裝iptables
如果你要改用iptables的話粱坤,需要安裝iptables服務(wù):
#安裝
sudo yum install iptables-services
#開啟iptables
sudo systemctl enable iptables
sudo systemctl enable ip6tables
#啟動服務(wù)
sudo systemctl start iptables
sudo systemctl start ip6tables
關(guān)閉防火墻
[root@VM_0_6_centos ~]# service iptables stop
Redirecting to /bin/systemctl stop iptables.service
[root@VM_0_6_centos ~]# service iptables status
Redirecting to /bin/systemctl status iptables.service
● iptables.service - IPv4 firewall with iptables
Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Thu 2019-09-26 21:28:33 CST; 6s ago
Process: 9537 ExecStop=/usr/libexec/iptables/iptables.init stop (code=exited, status=0/SUCCESS)
Process: 9354 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
Main PID: 9354 (code=exited, status=0/SUCCESS)
Sep 26 21:27:28 VM_0_6_centos systemd[1]: Starting IPv4 firewall with iptables...
Sep 26 21:27:28 VM_0_6_centos iptables.init[9354]: iptables: Applying firewall rules: [ OK ]
Sep 26 21:27:28 VM_0_6_centos systemd[1]: Started IPv4 firewall with iptables.
Sep 26 21:28:33 VM_0_6_centos systemd[1]: Stopping IPv4 firewall with iptables...
Sep 26 21:28:33 VM_0_6_centos iptables.init[9537]: iptables: Setting chains to policy ACCEPT: filte... ]
Sep 26 21:28:33 VM_0_6_centos iptables.init[9537]: iptables: Flushing firewall rules: [ OK ]
Sep 26 21:28:33 VM_0_6_centos systemd[1]: Stopped IPv4 firewall with iptables.
Hint: Some lines were ellipsized, use -l to show in full.
[root@VM_0_6_centos ~]#
Stopped IPv4 firewall with iptables 說明防火墻已關(guān)閉
2,安裝 jdk
2.1 方式一:普通安裝方式:(下載慢)
yum install java
java -version
2.2 方式二:安裝指定版本:java1.8(下載慢)
- 在線下載jdk (下載比較慢)
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
- 賦權(quán)限
chmod +x jdk-8u131-linux-x64.rpm
- 進行安裝
rpm -ivh jdk-8u131-linux-x64.rpm
- 查看是否安裝成功
java -version
默認安裝路徑為 /usr/java/jdk1.8.0_131
- 編輯環(huán)境變量
vim /etc/profile
環(huán)境變量為
export JAVA_HOME=/usr/java/jdk1.8.0_131
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- 使得配置立即生效
source /etc/profile
- 查看是否安裝成功
javac
java -version
echo $PATH
2.3 方式三:下載jdk1.8上傳linux服務(wù)器(安裝快-推薦)
下載:jdk-8u221-linux-x64.tar.gz
放到 /usr/local 瓷产,解壓
tar -zxvf jdk-8u221-linux-x64.tar.gz
改名 jdk1.8
mv jdk1.8.0_221 jdk1.8
[root@VM_0_6_centos local]# ls
bin etc games include jdk1.8 lib lib64 libexec qcloud sbin share src yd.socket.server
配置jdk1.8環(huán)境變量
[root@VM_0_6_centos jdk1.8]# pwd
/usr/local/jdk1.8
[root@VM_0_6_centos jdk1.8]# vi /etc/profile
環(huán)境變量為:
export JAVA_HOME=/usr/local/jdk1.8
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
退出文件站玄,保存
按Esc鍵 輸入:wq 保存并退出
讓配置文件生效:
[root@VM_0_6_centos jdk1.8]# source /etc/profile
查看是否配置成功:
[root@VM_0_6_centos jdk1.8]# java -version
java version "1.8.0_221"
若出現(xiàn)jdk版本號,則安裝并配置環(huán)境變量成功
如果提示命令找不到的話濒旦,查看一下jdk的配置路徑是否錯誤株旷。
刪除安裝包(可選):rm -rf jdk-8u221-linux-x64.tar.gz
3、安裝 git
方式一:git安裝(舊版本)
[root@VM_0_6_centos local]# yum install git
[root@VM_0_6_centos local]# git --version
git version 1.8.3.1
方式二:gti安裝(最新版本—推薦)
1尔邓、獲取github最新的Git安裝包下載鏈接灾常,下載新版本 git-2.9.5.tar.gz 上傳到linux;
2铃拇、壓縮包解壓:
sudo tar -zxvf git-2.9.5.tar.gz
3、進入解壓后的文件夾:
cd git-2.9.5
4沈撞、執(zhí)行編譯:耐心等待編譯即可
make prefix=/usr/local/git all
5慷荔、安裝Git至/usr/local/git路徑,命令為
make prefix=/usr/local/git install
6缠俺、打開環(huán)境變量配置文件显晶,命令 ,在底部加上Git相關(guān)配置信息:
vim /etc/profile
PATH=$PATH:/usr/local/git/bin
export PATH
然后wq保存壹士,退出磷雇!
讓配置文件生效:
source /etc/profile
7、輸入命令 git --version 躏救,查看安裝的git版本唯笙,校驗通過,安裝成功盒使。
8崩掘、刪除安裝包(可選):rm -rf git-2.9.5.tar.gz
9、查看git安裝路徑:
Linux-如果不清楚自己的Git安裝在哪個路徑下少办,終端執(zhí)行
whereis git
配置:/usr/local/git/bin/git
生成ssh密鑰及配置git
ssh公鑰可以配置gitlab苞慢、github等,
ssh私鑰可配置jenkins憑證等英妓。
用戶和郵箱不要求真實
[root@VM_0_6_centos ~]# git config --global user.name "zhengja"
[root@VM_0_6_centos ~]# git config --global user.email "zhengja@dist.com"
[root@VM_0_6_centos ~]# ssh-keygen -t rsa -C "zhengja@dist.com"
Enter file in which to save the key (/root/.ssh/id_rsa):
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:EqKVJUBpxVYpswJifGiXyplLTUcBYFNaMxaODZQPUmc zhengja@dist.com
The key's randomart image is:
+---[RSA 2048]----+
|oOO&E++. |
|=B%BB=. |
|*=@+=+. |
| *.=.. . |
|. o. . S |
| . . |
| |
| |
| |
+----[SHA256]-----+
拿到公鑰配置gitlab: (也可以配置github等)
[root@VM_0_6_centos local]# cd /root/.ssh/
[root@VM_0_6_centos .ssh]# ls
authorized_keys id_rsa id_rsa.pub known_hosts
[root@VM_0_6_centos .ssh]# vim id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDcArp9fBpi7CWJ50dQQTHbLfRkMyhVuox7bFEeYu3kaFYO3ECInfiBEK8PdYAKPjGWRirYQGCBQlsSzGd4F3sVTQH4ePk0bk/iAwnZsgOBgMgyZW6c00u+afJ/h8PNRK2xr60kB3n4no4UDov4hsuGdCKhavrHRzs3s6H+b7WKxILdSwZ7BpduGZGCOug8JtcnwF1mmMKi0YH0KrIxnrOR9GHT+wHAyJ5WjYU4Xzr+ZIGN6MfrM7X99y/uyMsrv8nzliMxWpFxduYAkKkfrqf46Y18oZfn5VdXhfnvyd+FqWTPdtJF2EZtKdhwGnouuyTdESQP3PPacFM1ZeW58R/T zhengja@dist.com
測試:git命令克隆sshUrl到本地
git clone sshURL
4挽放、安裝 maven
下載 apache-maven-3.6.2-bin.zip 绍赛,上傳到linux系統(tǒng)并解壓
[root@VM_0_6_centos local]# ls
apache-maven-3.6.2-bin.zip etc include lib libexec sbin src
bin games jdk1.8 lib64 qcloud share yd.socket.server
[root@VM_0_6_centos local]# unzip apache-maven-3.6.2-bin.zip
[root@VM_0_6_centos local]# ls
apache-maven-3.6.2 bin games jdk1.8 lib64 qcloud share yd.socket.server
apache-maven-3.6.2-bin.zip etc include lib libexec sbin src
配置maven環(huán)境變量:
[root@VM_0_6_centos apache-maven-3.6.2]# pwd
/usr/local/apache-maven-3.6.2
[root@VM_0_6_centos apache-maven-3.6.2]# vim /etc/profile
末尾添加(路徑要正確)
export MAVEN_HOME=/usr/local/apache-maven-3.6.2
export PATH=$MAVEN_HOME/bin:$PATH
重新加載配置-->測試maven是否配置成功
[root@VM_0_6_centos apache-maven-3.6.2]# . /etc/profile
[root@VM_0_6_centos apache-maven-3.6.2]# mvn -version
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T23:06:16+08:00)
Maven home: /usr/local/apache-maven-3.6.2
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /usr/local/jdk1.8/jre
刪除安裝包(可選):rm -rf apache-maven-3.6.2-bin.zip
5、安裝 tomcat
下載 tomcat8 ,上傳到linux辑畦,并解壓
[root@VM_0_6_centos local]# unzip apache-tomcat-8.5.46.zip
[root@VM_0_6_centos local]# ls
apache-maven-3.6.2 bin include lib64 sbin yd.socket.server
apache-tomcat-8.5.46 etc jdk1.8 libexec share
apache-tomcat-8.5.46.zip games lib qcloud src
配置tomcat
給tomcat下的所有文件授給任何人都可執(zhí)行的權(quán)限
[root@VM_0_6_centos local]# cd apache-tomcat-8.5.46/
[root@VM_0_6_centos apache-tomcat-8.5.46]# chmod a+x -R *
修改tomcat端口為8090
[root@VM_0_6_centos apache-tomcat-8.5.46]# vim conf/server.xml
<Connector port="8090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
啟動tomcat:
[root@VM_0_6_centos apache-tomcat-8.5.46]# bin/startup.sh
查看tomcat是否啟動成功:
[root@VM_0_6_centos apache-tomcat-8.5.46]# ps -ef|grep tomcat
root 22857 1 29 19:12 pts/0 00:00:02 /usr/local/jdk1.8/bin/java -Dcatalina.base=/usr/local/apache-tomcat-8.5.46 -Dcatalina.home=/usr/local/apache-tomcat-8.5.46 -Djava.io.tmpdir=/usr/local/apache-tomcat-8.5.46/temp org.apache.catalina.startup.Bootstrap start
root 27474 19080 0 10:10 pts/0 00:00:00 grep --color=auto tomcat
啟動成功標識吗蚌!
關(guān)閉tomcat:
首先,進入Tomcat下的bin目錄
cd /usr/local/tomcat/bin
使用./shutdown.sh或者是sh shutdown.sh關(guān)閉Tomcat
想直接直接殺死Tomcat進程(進程號: 22857)航闺,使用kill命令
kill -9 22857
到此節(jié)點環(huán)境搭建完畢!