一. 安装JDK

在/etc/profile中配置环境变量

export JAVA_HOME=/usr/local/jdk
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH

让环境变量生效:

  • 永久生效:重启 Linux
  • 临时生效:./etc/profile 或者 source /etc/profile 有效范围是当前会话[终端]

验证

java -version

二. 安装Tomcat

tar xzvf apache-tomcat-7.0.68.tar.gz
cp -r apache-tomcat-7.0.68 /usr/local/tomcat
cd /usr/local/tomcat/bin

./startup.sh
tail -f tomcat/logs/catalina.out
或者
tomcat/bin/startup.sh & tail

三. 安装MySQL

tar xzvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz
cp -r mysql-5.7.27-linux-glibc2.12-x86_64 /usr/local/mysql
groupadd mysql
useradd -r -g mysql mysql
cd /usr/local/mysql
chown -R mysql:mysql .
cd /usr/local/mysql/bin

./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US

#记录 A temprary password is generated for root@localhost: ********

# mysql5.7 要求系统中 libtinfo.so.5,CentOS 中是 libtinfo.so.6.1。
ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5
ln -s /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5

cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysql
service mysql start
systemctl enable mysql

ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
# 密码是在初始化时 mysql 分配的 A temprary password is generated for root@localhost: ********
mysql -u root -p
# 此时修改的密码是针对前边-u 参数指定的用户
> set password=password("your password");
# MySQL默认只能在localhost上访问
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your password' WITH GRANT OPTION;
> flush privileges;