Centos 6.4安裝:防火牆+JDK7+tomcat8+mysql
(一)防火牆
1、centos6.4在/etc/sysconfig/下面沒有iptables檔案,需要自建一個iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
2、關閉/開啟/重啟防火牆(重啟後可以復原)
/etc/init.d/iptables stop
/etc/init.d/iptables start
/etc/init.d/iptables restart
/etc/init.d/iptables status
service iptables start
service iptables
stop
service iptables restart
3.永久性關閉防火牆(重啟後不可復原)
chkconfigiptables off
chkconfigiptables on
(二)JDK7
1、把下載好的jdk-7u51-linux-x64.rpm上傳到/usr/local/目錄下面。
2、不指定安裝目錄執行rpm -ivh jdk-7u51-linux-x64.rpm就安裝在/usr/java。
[[email protected] local]# rpm -ivh jdk-7u51-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
3、通過java、javac、java -version檢查是否安裝成功。
4、配置環境變數:[[email protected] java]# vi + /etc/profile
JAVA_HOME=/usr/java/jdk1.7.0_51
JRE_HOME=/usr/java/jdk1.7.0_51/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
5、使修改生效
[[email protected] java]# source /etc/profile
[[email protected] java]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.7.0_51/bin:/usr/java/jdk1.7.0_51/jre/bin
(三)tomcat8
1、解壓:tar -zxvf apache-tomcat-8.0.3.tar.gz
2、移動:mv apache-tomcat-8.0.3 /home/leanyu/tomcat
3、配置:vi /etc/profile 最後加上:export TOMCAT_HOME=/home/leanyu/tomcat
4、執行: source /etc/profile
5、啟動:
cd /home/leanyu/tomcat、bin/
chmod +x *.sh
./ catalina.sh start
6、修改防火牆:vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT #允許8080埠通過防火牆
注意:該規則應新增到預設的22埠這條規則的下面。
/etc/init.d/iptables restart #最後重啟防火牆使配置生效
最後,在瀏覽器輸入伺服器的ip:8080,如下:http://192.168.1.36:8080, 就可以開啟tomcat的預設頁面了。
(四)mysql參考下面連結
http://blog.csdn.net/heirenheiren/article/details/20576935