腾讯云服务器CentOS7系统上安装JDK+Tomcat+MySQL
安装jdk
下载jdk可以去官网查看不同版本的jdk进行下载,不过现在oracle要求账户登陆才能下载以前版本的jdk。我这里下载的是jdk-7u79-linux-x64.tar.gz。
mv移动到/usr/local/software/jdk(这是我在local目录下新建的文件夹)下,解压缩。
tar -zxvf jdk-7u79-linux-x64.tar.gz
配置环境变量:修改/etc/profile文件,在最后添加
JAVA_HOME=/usr/local/software/jdk/jdk1.7.0_79/
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin/
export PATH JAVA_HOME CLASSPATH
保存退出
使文件立即生效
source /etc/profile
检验
javac
安装tomcat
可以去官网下载,我下载的版本是apache-tomcat-8.5.11.tar.gz
mv移动到/usr/local/software/tomcat(这是我在local目录下新建的文件夹)下,解压缩。
tar -zxvf apache-tomcat-8.5.11.tar.gz
检验 cd /usr/local/software/tomcat/apache-tomcat-8.5.11/bin
执行./startup.sh
出现Tomcat started.表示成功.
由于http协议的默认端口号为80,这里我们需要修改tomcat的端口号,进入tomcat目录下,找到conf/server.xml,编辑
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
修改为
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
保存退出即可。
安装mysql
查看centos的系统版本
[root@VM_18_45_centos tomcat]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
由于CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了。以前的安装方法会失败。这里有两种方案(可查看文章末尾的引用)。其中一种为:
官网下载安装mysql:
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
安装完成后启动mysql
systemctl start mysql
初始安装mysql,root用户没有密码
[root@VM_18_45_centos tmp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
设置密码
mysql> set password for 'root'@'localhost' =password('password');
Query OK, 0 rows affected (0.00 sec)
mysql>
参考阅读
centos7 mysql数据库安装和配置 http://www.cnblogs.com/starof/p/4680083.html
网友评论