CentOS 7系統安裝和配置請到網上查詢相關資料(百度經驗裏有),注意安裝的時候,必定要選擇安裝的軟件和設置網絡鏈接爲打開,否則系統默認按照最小化安裝,禁用網絡鏈接(後期配置很煩)html
------------------------------------------------------------------------------------------------------------java
1、安裝和配置JAVA開發環境node
[root@promote test]# java -version ——查看java版本信息python
openjdk version "1.8.0_65"mysql
OpenJDK Runtime Environment (build 1.8.0_65-b17)linux
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)web
[root@promote test]#sql
[root@promote test]# rpm -qa | grep java ——進一步查看JDK信息數據庫
javapackages-tools-3.4.1-11.el7.noarchapache
java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64
python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64
tzdata-java-2015g-1.el7.noarch
[root@promote test]#
/*上述標記顏色的爲已安裝的java版本,下面5條指令爲卸載指令*/
[root@promote test]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
[root@promote test]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64
[root@promote test]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.65-3.b17.el7.x86_64
[root@promote test]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64
[root@promote test]# rpm -e --nodeps tzdata-java-2015g-1.el7.noarch
[root@promote test]#
[root@promote test]# rpm -qa | grep java ——從新查看JDK信息(已卸載)
javapackages-tools-3.4.1-11.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
[root@promote test]#
從Oracle網站上下載最新的JDK文件
下載網址:http://www.oracle.com/technetwork/java/javase/downloads/index.html
JDK版本:jdk-8u111-linux-x64.rpm ——這裏選擇下載rpm格式的,方便安裝
用瀏覽器下載完成後,默認是存放在/home/test/downloads文件夾下(安裝了桌面環境),執行cd /home/test/downloads/ 跳轉到downloads目錄下(裝了gnome和網絡應用軟件,也能夠直接鏈接網址下載)
[root@promote test]# cd /home
[root@promote home]# ls
test
[root@promote home]# cd test/
[root@promote test]# ls
Desktop Documents Downloads Music Pictures Public Templates Videos
[root@promote test]# cd Downloads/
[root@promote Downloads]# ls
jdk-8u111-linux-x64.rpm ——找到下載的jdk文件後將文件移到/usr/local目錄下
[root@promote Downloads]# mv jdk-8u111-linux-x64.rpm /usr/local/
[root@promote Downloads]# cd /usr/local
[root@promote local]# ls
bin etc games include jdk-8u111-linux-x64.rpm lib lib64 libexec sbin share src
[root@promote local]#
[root@promote local]# rpm -ivh jdk-8u111-linux-x64.rpm ——執行安裝指令
Preparing... ################################# [100%]
Updating / installing...
1:jdk1.8.0_111-2000:1.8.0_111-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar... ——安裝完畢,JDK默認安裝在/usr/java中
[root@promote local]# ls
bin etc games include jdk-8u111-linux-x64.rpm lib lib64 libexec sbin share src
[root@promote local]# cd ..
[root@promote usr]# ls ——跳轉到/usr/java/,查看目錄中的的文件
bin etc games include java lib lib64 libexec local sbin share src tmp
[root@promote usr]# cd java/
[root@promote java]# ll
total 4
lrwxrwxrwx. 1 root root 16 Nov 17 21:33 default -> /usr/java/latest
drwxr-xr-x. 9 root root 4096 Nov 17 21:33 jdk1.8.0_111
lrwxrwxrwx. 1 root root 22 Nov 17 21:33 latest -> /usr/java/jdk1.8.0_111
[root@promote java]# cd
[root@promote ~]#
/*執行下面三條指令驗證java安裝結果,都出來指令即說明安裝成功*/
[root@promote ~]# java
[root@promote ~]# javac
[root@promote ~]# java -version
至此,Centos中java安裝完畢!
--------------------------------------------------------------------------------------------------------
配置環境變量
個人機器安裝完jdk-7-linux-x64.rpm後不用配置環境變量也能夠正常執行javac、java –version操做,但爲了之後的使用方便,仍是配置一下,具體操做以下:
修改系統環境變量文件
vi + /etc/profile
向文件裏面追加如下內容:
JAVA_HOME=/usr/java/jdk1.8.0_111
JRE_HOME=/usr/java/jdk1.8.0_111/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
使修改生效
[root@localhost ~]# source /etc/profile //使修改當即生效
[root@localhost ~]# echo $PATH //查看PATH值
查看系統環境狀態
[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_25/bin:/usr/java/jdk1.8.0_25/jre/bin
[root@promote bin]# $JAVA_HOME
bash: /usr/java/jdk1.8.0_111: Is a directory
[root@promote bin]# $JRE_HOME
bash: /usr/java/jdk1.8.0_111/jre: Is a directory
[root@promote bin]#
============================================================
2.安裝和配置tomcat
網上下載tomcat到本機,默認存放在/home/test/Downloads/目錄下
下載網址:http://tomcat.apache.org/download-80.cgi
Tomcat版本包:apache-tomcat-8.0.39.tar.gz
[root@promote ~]# cd /home/test/
[root@promote test]# ls
Desktop Documents Downloads Music Pictures Public Templates Videos
[root@promote test]# cd Downloads/
[root@promote Downloads]# ls ——進入Downloads目錄查看文件
apache-tomcat-8.0.39.tar.gz
[root@promote Downloads]# mv apache-tomcat-8.0.39.tar.gz /usr/local
[root@promote Downloads]# cd /usr/local
[root@promote local]# ls ——移動到/usr/local/目錄下
apache-tomcat-8.0.39.tar.gz bin etc games include lib lib64 libexec sbin share src
[root@promote local]# mkdir tomcat8 ——建立tomcat目錄並解壓文件到此目錄
[root@promote local]# tar -zxvf apache-tomcat-8.0.39.tar.gz -C /usr/local/tomcat8/
[root@promote local]# ls
apache-tomcat-8.0.39.tar.gz bin etc games include lib lib64 libexec sbin share src tomcat8
[root@promote local]#
[root@promote local]# cd tomcat8/
[root@promote tomcat8]# ls
apache-tomcat-8.0.39 ——發現多一級目錄
[root@promote tomcat8]# cd apache-tomcat-8.0.39/
[root@promote apache-tomcat-8.0.39]# ls ——進入目錄後纔是tomcat安裝文件
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
/*執行以下語句更換tomcat的安裝目錄,並刪除原目錄*/
[root@promote local]# mv /usr/local/tomcat8/apache-tomcat-8.0.39/* /usr/local/tomcat8/
[root@promote local]# cd tomcat8/
[root@promote tomcat8]# ls
apache-tomcat-8.0.39 bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@promote tomcat8]# cd apache-tomcat-8.0.39/
[root@promote apache-tomcat-8.0.39]# ls
[root@promote apache-tomcat-8.0.39]# cd ..
[root@promote tomcat8]# rm -rf apache-tomcat-8.0.39/
[root@promote tomcat8]# ls ——子一級目錄已刪除
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@promote tomcat8]# cd ..
[root@promote local]# ls
apache-tomcat-8.0.39.tar.gz bin etc games include lib lib64 libexec sbin share src tomcat8
[root@promote local]# rm -rf apache-tomcat-8.0.39.tar.gz ——刪除安裝包
[root@promote local]#
至此,tomcat安裝完成,tomcat配置的相關操做(包括修改端口、配置JVM和默認的java環境)網上資源有不少,此處不作描述。(後期若是有時間再整理)
--------------------------------------------------------------------------------------------------------
啓動和調試tomcat
[root@promote local]# /usr/local/tomcat8/bin/startup.sh ——啓動tomcat
Using CATALINA_BASE: /usr/local/tomcat8
Using CATALINA_HOME: /usr/local/tomcat8
Using CATALINA_TMPDIR: /usr/local/tomcat8/temp
Using JRE_HOME: /usr/java/jdk1.8.0_111/jre
Using CLASSPATH: /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jar
Tomcat started. ——tomcat啓動成功,本機能夠正常登陸
[root@promote local]#
--------------------------------------------------------------------------------------------------------
Tomcat啓動成功後,並不意味着工做的結束,還須要放開tomcat配置的端口,不然外網是沒法訪問tomcat發佈的應用程序的,具體操做以下(假設須要放開8080和80端口):
[root@promote bin]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@promote bin]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[root@promote bin]# firewall-cmd --reload
success
[root@promote bin]#
——至此,tomcat的安裝、配置和發佈即完成。
============================================================
3.安裝和配置mysql
CentOS 7的yum源中沒有正常安裝MySQL時的mysql-sever文件,須要去官網上下載
[root@promote local]# wget http://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm
[root@promote local]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm
[root@promote local]# yum install mysql-community-server
安裝完畢後,密碼修改有些問題,參照:http://blog.csdn.net/yzl11/article/details/52643276
或者參照:《Mysql-01.安裝和配置》中Linux系統下安裝和配置mysql章節:https://my.oschina.net/u/3016592/blog/784166
MySql安裝完畢後,建立數據庫以後執行受權指令
grant all on db_name.* to user_name@localhost identified by 'password'; ——本地用戶
grant all on db_name.* to user_name@'%' identified by 'password'; ——全部用戶
grant all on db_name.* to user_name@'IP' identified by 'password'; ——指定IP用戶
受權完畢後,默認狀況下是沒法訪問的,由於CentOS防火牆屏蔽了mysql的3306端口,須要開啓CentOS的3306端口,執行以下操做;
[root@promote ~]#
[root@promote ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@promote ~]# firewall-cmd --reload
success
[root@promote ~]#
另外,也能夠執行以下指令中止或者禁用防火牆(不推薦)
systemctl stop firewalld.service #中止
systemctl disable firewalld.service #禁用