以下使用 linux centos系統
1、下載jdk-8u111-linux-x64.tar.gz
2、解壓該文件,將解壓後的文件復制到 /usr/local/jdk1.7 目錄下。如圖:
在這裡 jdk1.7 目錄就是我解壓後的文件內容。
3、配置環境變量
進入etc目錄下編輯profile文件
文件內容:
# /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac } if [ -x /usr/bin/id ]; then if [ -z "$EUID" ]; then # ksh workaround EUID=`id -u` UID=`id -ru` fi USER="`id -un`" LOGNAME=$USER MAIL="/var/spool/mail/$USER" fi # Path manipulation if [ "$EUID" = "0" ]; then pathmunge /usr/sbin pathmunge /usr/local/sbin else pathmunge /usr/local/sbin after pathmunge /usr/sbin after fi HOSTNAME=`/usr/bin/hostname 2>/dev/null` HISTSIZE=1000 if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth else export HISTCONTROL=ignoredups fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL # By default, we want umask to get set. This sets it for login shell # Current threshold for system reserved uid/gids is 200 # You could check uidgid reservation validity in # /usr/share/doc/setup-*/uidgid file if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then umask 002 else umask 022 fi for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" else . "$i" >/dev/null fi fi done unset i unset -f pathmungeView Code
添加關於JDK環境變量的配置:在該文件末尾添加下面代碼
JAVA_HOME="/usr/local/jdk1.7" CLASS_PATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib" PATH=".:$PATH:$JAVA_HOME/bin"
export JAVA_HOME
4、測試是否安裝成功
a、讓更改後的文件立即生效 ; 執行命令: source /etc/profile
b、輸入命令 java -version 結果如圖:
1、下載tomcat apache-tomcat-7.0.70.tar.gz
2、將解壓後的文件移動到 /usr/local/tomcat1.7 如圖:
3、配置環境變量
在/etc/profile 文件末尾添加如下內容
CATALINA_HOME="/usr/local/tomcat1.7" export CATALINA_HOME
4、測試tomcat是否安裝成功
a、讓更改後的文件立即生效 ; 執行命令: source /etc/profile
b、進入tomcat bin目錄下執行命令 ./startup.sh
c、訪問 127.0.0.1:8080 看是否出現tomcat主頁
一般情況下JDK與tomcat的環境變量我們會寫在一起 在/etc/profile 文件末尾添加如下內容
JAVA_HOME="/usr/local/jdk1.7" CLASS_PATH="$JAVA_HOME/lib:$JAVA_HOME/jre/lib" PATH=".:$PATH:$JAVA_HOME/bin" CATALINA_HOME="/usr/local/tomcat1.7" export JAVA_HOME CATALINA_HOME
Centos 7使用firewalld代替了原來的iptables。下面記錄如何使用firewalld開放Linux端口:
1、開啟端口 執行命令:firewall-cmd --zone=public --add-port=80/tcp --permanent 命令含義: --zone #作用域 --add-port=80/tcp #添加端口,格式為:端口/通訊協議 --permanent #永久生效,沒有此參數重啟後失效 2、重啟防火牆 命令:firewall-cmd --reload
http://xxxxxx/Linuxjc/1175963.html TechArticle