安裝系統環境是: centos6.5 64位
一.安裝jdk
1.下載Java文件jdk-6u45-Linux-x64.bin
2.運行./jdk-6u45-linux-x64.bin
3.移動該文件到/usr/local/jdk目錄下
mv jdk-6u45-linux-x64 /usr/local/jdk
4.配置java環境變數,在文件/etc/profile最後添加以下內容:
#set java
JAVA_HOME=/usr/local/jdk;export JAVA_HOME
JRE_HOME=/usr/local/jdk/jre;export JRE_HOME
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin;export PATH
export CLASSPATH=$CLASSPATH:$PATH:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib:$JRE_HOME/lib:.
5.source /etc/profile (重新激活)
6.運行java -version查看是否成功
二.安裝tomcat
1.下載tomcat文件:apache-tomcat-7.0.47.tar.gz
2.解壓tar -zxvf apache-tomcat-7.0.47.tar.gz
3.移動該文件到/usr/local下,並命名為tomcat
mv apache-tomcat-7.0.47 /usr/local/tomcat
4.到tomcat/bin目錄下setclasspath.sh文件中設置java環境,加入以下兩行即可:
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=/usr/local/jdk/jre
5.設置tomcat 服務啟動
把下面內容保存到/etc/init.d/目錄,文件名為tomcat
#!/bin/bash
# /etc/rc.d/init.d/tomcat
# init script for tomcat precesses
#
# processname: tomcat by ton
# description: tomcat is a j2se server
# chkconfig: 2345 86 16
# description: Start up the Tomcat servlet engine.
set -m (有時不加這個,secureFX會話失效時,會導致tomcat自動stop)
CATALINA_HOME="/usr/local/tomcat"
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
echo -e "/atomcat: unable to locate functions lib. Cannot continue."
exit -1
fi
# running tomcat services
RETVAL=$?
case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/startup.sh
fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/shutdown.sh
fi
;;
restart)
if [ -f $CATALINA_HOME/bin/startup.sh ];then
echo $"Starting Tomcat"
$CATALINA_HOME/bin/startup.sh
fi
sleep 5
if [ -f $CATALINA_HOME/bin/shutdown.sh ];then
echo $"Stopping Tomcat"
$CATALINA_HOME/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
6.為該文件添加運行許可權
chmod +x /etc/init.d/tomcat
三.安裝MySQL
linux下主要是編譯安裝,需准備:cmake工具
1.yum install gcc gcc-c++ ncurses-devel perl (安裝編譯源碼所需的工具和庫)
2.下載cmake-3.0.1.tar.gz ,然後輸入命令:
tar -xzvf cmake-3.0.1.tar.gz
cd cmake-3.0.1
./bootstrap ; make ; make install
3.新增mysql用戶組和用戶命令:
groupadd mysql
useradd -r -g mysql mysql
4.新建mysql安裝目錄和存放數據目錄:
mkdir -p /usr/local/mysql
cd /usr/local/mysql
chown -R mysql:mysql . (分配許可權)
mkdir -p /var/mysqldata
cd /var/mysqldata
chown -R mysql:mysql . (分配許可權)
5.下載mysql-5.5.38.tar.gz ,解壓:
tar -zxvf mysql-5.5.38.tar.gz
cd mysql-5.5.38(先進入目錄下)
6.(先進入mysql-5.5.38目錄下)再執行cmake命令:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/var/mysqldata/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysqldata \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
7.再編譯:
make
make install
8.復制配置文件,在/usr/local/mysql下執行:
cp support-files/my-medium.cnf /etc/my.cnf
9 初始化資料庫
執行前需賦給scripts/mysql_install_db文件執行許可權
chmod 755 scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ \
--datadir=/var/mysqldata/
10. 設置mysqld的開機啟動
cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig mysql on
11.MySQL配置環境變數
export PATH=/usr/local/mysql/bin:$PATH
alias mysql_start="mysqld_safe &"
alias mysql_stop="mysqladmin –u root -p shutdown"
source /etc/profile (重啟配置)
12.啟動mysql服務
/etc/init.d/mysql start
ps -ef |grep mysql (命令查看是否啟動)
13. 登陸mysql
# mysql -u root –p
14.修改MySQL用戶root的密碼
mysqladmin -u root password '123456' (更新密碼)
㈡ centos瀹夎卝ava鐨勯棶棰
鏄涓嶆槸涓嬭澆鐨勬枃浠舵牸寮忔湁闂棰橈紵
闇瑕佷笅杞界殑鏄疞inux self-extracting file鑰岄潪Linux RPM in self-extracting file錛屼綘鍐嶆鏌ヤ竴涓嬨
鍙浠ユ寜鐓т互涓嬫ラよ繘琛岋細
絎涓姝ワ細鏌ョ湅Linux鑷甯︾殑JDK鏄鍚﹀凡瀹夎 錛堝嵏杞絚entOS宸插畨瑁呯殑1.4錛
<1># rpm -qa|grep jdk 鈫 鏌ョ湅jdk鐨勪俊鎮鎴栫洿鎺ユ墽琛
鎴
# rpm -q jdk
鎴
# java -version
<2># rpm -qa | grep gcj 鈫 紜璁gcj鐨勭増鏈鍙
<3># yum -y remove java-1.4.2-gcj-compat 鈫 鍗歌澆gcj
絎浜屾ワ細瀹夎匤DK
<1>浠嶴UN涓嬭澆jdk-1_5_0_14-linux-i586-rpm.bin鎴杍dk-1_5_0_14-linux-i586.bin
鍦/usr涓嬫柊寤簀ava鏂囦歡澶癸紝灝嗗畨瑁呭寘鏀懼湪/usr/java鐩褰曚笅
# mkdir /usr/java
<2>瀹夎匤DK
# cd /usr/java
鈶爅dk-1_5_0_14-linux-i586-rpm.bin鏂囦歡瀹夎
# chmod 777 jdk-1_5_0_14-linux-i586-rpm.bin 鈫 淇鏀逛負鍙鎵ц
# ./jdk-1_5_0_14-linux-i586-rpm.bin 鈫 閫夋嫨yes鍚屾剰涓婇潰鐨勫崗璁
# rpm -ivh jdk-1_5_0_14-linux-i586.rpm 鈫 閫夋嫨yes鐩村埌瀹夎呭畬姣
鈶jdk-1_5_0_14-linux-i586.bin鏂囦歡瀹夎
# chmod a+x jdk-1_5_0_14-linux-i586.bin 鈫 浣垮綋鍓嶇敤鎴鋒嫢鏈夋墽琛屾潈闄
# ./jdk-1_5_0_14-linux-i586.bin 鈫 閫夋嫨yes鐩村埌瀹夎呭畬姣
絎涓夋ワ細閰嶇疆鐜澧冨彉閲
<1># vi /etc/profile
<2>鍦ㄦ渶鍚庡姞鍏ヤ互涓嬪嚑琛岋細
export JAVA_HOME=/usr/java/jdk1.6.0_10
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
<3># reboot 鈫 閲嶅惎鏈哄櫒閰嶇疆鐢熸晥
鎴戝湪鍋氱浜屼腑鏂囩綉http://dearzw.com寰楁椂鍊欎篃閬囪佽繃榪欎釜闂棰橈紝鎸夌収涓婇潰鐨勬ラゅ簲璇ュ氨OK浜嗐