首先将jdk-7-u79-linux-x64.tar.gz、mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz、apache-tomcat-7.0.84.tar.gz 下载好放在"/usr/java/"目录下
-------------------java-------------------:
1.解压缩
[root@localhost java]# tar zxvf jdk-7-u79-linux-x64.tar.gz
2.设置环境变量
[root@localhost java]# vi /etc/profile
在profile中添加如下内容:
<!--复制代码-->
#set java environmentJAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
<!--复制代码-->
让修改生效:[root@localhost java]# source /etc/profile
3.验证JDK有效性
[root@localhost java]# java -version
<!--控制台显示-->
java version "1.7.0_79"Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
<!--控制台显示-->
-------------------mysql-------------------:
1、解压缩
tar zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
2、创建data目录
mkdir /usr/java/mysql/data
3、创建mysql用户组及其用户
groupadd mysql
useradd -r -g mysql mysql
4、初始化数据
<--! 复制代码 -->
[root@localhost mysql] ./bin/mysql_install_db --user=mysql --basedir=/usr/java/mysql/ --datadir=/usr/java/mysql/data/
<--! 复制代码 -->
2016-01-20 02:47:35 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-01-20 02:47:45 [WARNING] The bootstrap log isn't empty:
2016-01-20 02:47:45 [WARNING] 2016-01-19T18:47:36.732678Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2016-01-19T18:47:36.750527Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-01-19T18:47:36.750560Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
<!--控制台显示-->
5、复制配置文件到 /etc/my.cnf
cp -a ./support-files/my-default.cnf /etc/my.cnf (选择y)
<!--控制台显示-->
cp -a ./support-files/mysql.server /etc/init.d/mysqld
修改my.cnf文件
vi /etc/my.cnf
<--! 复制代码 -->
basedir = /usr/local/mysql /usr/java/mysql
datadir = /usr/local/mysql/data /usr/java/mysql/data
port = 3306
# server_id = .....
socket = /tmp/mysql.sock
character-set-server = utf8
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
<--! 复制代码 -->
7、创建ln
ln -s /usr/java/mysql/bin/mysql /usr/bin/
cd /usr/local/bin
ln -fs /usr/java/mysql/bin/mysql mysql
8、启动服务
service mysqld start
9、初始化密码
mysql5.7会生成一个初始化密码,在root中.mysql_secret文件中。
[root@localhost ~]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2017-03-16 00:52:34
ws;fmT7yh0CM
10、登录并修改密码
[root@localhost ~]# mysql -u root -p
alter user root@localhost identified by '123456';
11、设置开机自启动
赋予可执行权限
chmod +x /etc/init.d/mysqld
添加服务
chkconfig --add mysqld
chkconfig --list
chkconfig --level 345 mysql on 345都是on则成功
12、导入数据库
create database 数据库名;
导入 mysql -u 用户名 -p 数据库名 < 导入的文件名.sql; sql文件在当前目录下;
导出 mysqldump -u 用户名 -p 目标数据库 > 导出的文件名.sql;
-----------------tomcat-------------------:
1.解压缩
tar zxvf apache-tomcat-7.0.84.tar.gz
2.指定运行jdk
在setclasspath.sh和catalina.sh中写入:
export JAVA_HOME=/home/manager/java/jdk1.8.0_121
export JRE_HOME=/home/manager/java/jdk1.8.0_121/jre/
3.向lib文件夹导入相关jar包
以上是小白在linux服务器上部署项目的过程,有不对的地方请指出来,以便大家共同进步~