本篇教程採用yum在線安裝的方式,對於不刻意要求工具版本的情況,採用yum安裝的方式將方便快捷很多。
打開網絡
在VMware中成功安裝CentOS 7.4後,首先需要將網絡設置爲開機自動啓動:
cd /etc/sysconfig/network-scripts
vi ifcfg-ens33
將ONBOOT由no改爲yes
:wq
systemctl restart network
重啓網絡
Xshell連接
ip addr
查看ip,根據ip連接xshell
安裝OpenJDK
搜索JDK有哪些可安裝的版本
yum search jdk
選擇版本進行安裝,這裏選擇OpenJDK Runtime Environment,例如:
yum -y install java-1.8.0-openjdk.x86_64
查看是否安裝成功
java -version
安裝Tomcat
搜索Tomcat有哪些可安裝的版本
yum search tomcat
選擇版本進行安裝,這裏選擇tomcat.noarch:
yum -y install tomcat.noarch
啓動Tomcat
systemctl start tomcat
設置開機自啓:
systemctl enable tomcat
檢查狀態:
systemctl status tomcat -l
這時主機無法訪問到VMware中Tomcat的主頁,原因在於CentOS啓用了防火牆,我們需要將8080端口開放出來,注意CentOS 7防火牆採用了firewall而不是之前版本的iptables,命令如下:
firewall-cmd --zone=public --add-port=8080/tcp --permanent
systemctl restart firewalld
重啓防火牆
安裝MariaDB
搜索MariaDB有哪些可安裝的版本
yum search mariadb
選擇版本進行安裝,這裏選擇mariadb-server.x86_64:
yum -y install mariadb-server.x86_64
開啓數據庫:
systemctl start mariadb
設置開機啓動:
systemctl enable mariadb
檢查狀態:
systemctl status mariadb -l
進入安全配置嚮導
mysql_secure_installation
Enter current password for root (enter for none): 沒有密碼,直接回車
Set root password? [Y/n] 輸入y,設置root密碼
New password: 輸入密碼
Re-enter new password: 再次輸入
Remove anonymous users? [Y/n] 輸入y,移除匿名用戶
Disallow root login remotely? [Y/n] 輸入n,可以使用root用戶遠程連接
Remove test database and access to it? [Y/n] 輸入y,刪除test數據庫
Reload privilege tables now? [Y/n] 輸入y,立即刷新權限表
登錄數據庫:
mysql -u root -p
輸入root密碼,然後設置遠程主機登錄,注意下面的password改成你的root密碼:
GRANT ALL PRIVILEGES ON *.* TO'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
刷新權限表
\q
退出數據庫
這裏我們需要開放3306端口,才能遠程主機進行登錄:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
systemctl restart firewalld
重啓防火牆