CentOS7安装openjdk、tomcat和mysql流程介绍

摘要:
--使用sharedthreadpool--˃1234567的“连接器”启动tomcat,在浏览器中输入要访问的IP地址,然后查看tomcat小猫页面。CentOS7打开80个端口。CentOS7使用firewalld而不是原始iptables--打开端口80,成功表示添加成功--˃#firewall cmd--zone=public-add port=80/tcp--永久˂!

首先是前戏,推荐一个远程工具Xshell和Xftp搭配使用,以下是Xshell的官网 
http://www.netsarang.com/products/xsh_overview.html


1.openjdk

How to download and install prebuilt OpenJDK packages

JDK 8

Debian, Ubuntu, etc.

On the command line, type:

$ sudo apt-get install openjdk-8-jre

The openjdk-8-jre package contains just the Java Runtime Environment. If you want to develop Java programs then please install the openjdk-8-jdk package.

Fedora, Oracle Linux, Red Hat Enterprise Linux, etc.

On the command line, type:

$ su -c “yum install java-1.8.0-openjdk”

The java-1.8.0-openjdk package contains just the Java Runtime Environment. If you want to develop Java programs then install the java-1.8.0-openjdk-devel package.

以上说了不同系统的安装方式,还指出命令只是安装了JRE,如果你需要开发应用程序,还需要另外安装(已经用加粗标识),想安装其它版本详情看openjdk官网介绍 
http://openjdk.java.net/install/

[root@VM_207_229_centos ~]# java -version
openjdk version "1.8.0_71"
OpenJDK Runtime Environment (build 1.8.0_71-b15)
OpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode)
  • 1
  • 2
  • 3
  • 4

2.tomcat

# cd /usr/local
# wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36.tar.gz
# tar xzf apache-tomcat-8.0.36.tar.gz
# mv apache-tomcat-8.0.36 tomcat
# ls
apache-tomcat-8.0.36.tar.gz  etc    include  lib64    logs    sa    share  tomcat   bin   games  lib   libexec  qcloud  sbin  src
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

个人习惯把tomcat放在/user/local下,下载后解压,再更名为tomcat 
想要其它版本的话……在以下地址找好路径下载 
https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/

修改配置文件conf/server.xml改为监听80端口,默认编码utf-8,并开启gzip压缩

<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" executor="tomcatThreadPool" URIEncoding="utf-8"   
               compression="on"   
               compressionMinSize="50" noCompressionUserAgents="gozilla, traviata"   
               compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" />
    <!-- A "Connector" using the shared thread pool-->
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

启动tomcat,在浏览器输入ip地址访问,看到tomcat小猫页面就行了。CentOS7开放80端口,Centos 7使用firewalld代替了原来的iptables。

<!-- 启动防火墙 -->
# systemctl start  firewalld
<!-- 开启80端口,出现success表明添加成功 -->
# firewall-cmd --zone=public --add-port=80/tcp --permanent
<!-- 重启防火墙 -->
# systemctl restart firewalld.service
<!-- 检查端口 -->
# firewall-cmd --permanent --zone=public --list-ports
<!-- 自启动防火墙 -->
#systemctl enable firewalld
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

还有更改默认访问地址,不想见到tomcat小猫(此步骤看个人需要)

<Engine name="Catalina" defaultHost="www.caihongwen.cn">

     <Realm className="org.apache.catalina.realm.LockOutRealm">
       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="www.caihongwen.cn"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Context docBase="blog" path="" debug="0"  reloadable="true"/>
               <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

请在意Host之间添加了一段代码

<Context docBase="blog" path="" debug="0"  reloadable="true"/>
  • 1

这个blog是放在webapps的项目war包名,通过ip或域名直接进入博客,不会出现tomcat小猫管理页面,第一次启动tomcat稍慢,新增加的war包需要重启一次才能起效。还有一个要点是对外开启80端口。


3.mysql

使用RPM包进行安装,这种安装进程会自动完成系统的相关配置,比较方便。 
另外有.tar.gz的压缩文件安装方式,推荐一个博客的介绍。 
http://blog.csdn.net/superchanon/article/details/8546254/

卸载原有MySQL或者Mariadb安装程序 
1、CentOs7版本默认情况下安装了mariadb-libs,必须先卸载才可以继续安装MySql。 
a) 查找以前是否安装mariadb-libs

# rpm -qa | grep -i mariadb-libs
  • 1

b)卸载已经安装的mariadb-libs

# yum remove mariadb-libs-5.5.44-2.el7.centos.x86_64
  • 1

2、查找以前是否安装MySQL

 # rpm -qa | grep -i mysql
  • 1

有的话,也删除

安装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
  • 1
  • 2
  • 3

成功安装之后重启mysql服务

# service mysqld restart
  • 1

初次安装mysql是root账户是没有密码的,设置密码的方法

# mysql -uroot
mysql> set password for 'root'@'localhost' = password('mypasswd');
  • 1
  • 2

远程授权连接mysql

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypasswd' WITH GRANT OPTION;
FLUSH   PRIVILEGES;
  • 1
  • 2

修改mysql默认编码

# vim /etc/my.cnf
  • 1

作出以下修改

[client]
default-character-set=utf8
[mysqld]
character_set_server=utf8
  • 1
  • 2
  • 3
  • 4

然后重启mysql

# service mysqld restart
# mysql -uroot -p
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

mysql> show variables like 'collation%';
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27

安装mysql-jdbc驱动

# yum install mysql-connector-java
  • 1

完工!!!

远程连接mysql,如果连接不上的话,可能是没开放3306端口。 
最后,分享一个mysql远程管理神器navicat,你懂的 
http://pan.baidu.com/s/1mh87vGc

免责声明:文章转载自《CentOS7安装openjdk、tomcat和mysql流程介绍》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇MySQL读写分离技术windows下 安装 rabbitMQ 及操作常用命令下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

my.cnf参数配置

[mysqld]basedir=/opt/djangostack-1.4-0/mysqldatadir=/opt/djangostack-1.4-0/mysql/dataport=3306socket=/opt/djangostack-1.4-0/mysql/tmp/mysql.socktmpdir=/opt/djangostack-1.4-0/mysql/...

mysql启动报错cannot allocate memory for the buffer pool处理

今天启动mysql服务器时失败了。去/var/log/mysql/查看error.log,报错信息如下: 160123 22:29:26 InnoDB: Initializing buffer pool, size = 200.0M InnoDB: mmap(214630400 bytes) failed; errno 12160123 22:29:26...

cmd 安装mysql

838444958 http://www.runoob.com/mysql/mysql-install.html (cmd)Aa410766383 mysql password bin目录下: net start mysql 启动mysqlmysql -u root -p 打开mysql输入mysql密码:+9C5toB#1IBm改变密码alter...

mysql++ 3.2.3 源码安装

https://tangentsoft.com/mysqlpp/home 下载 wgethttps://tangentsoft.com/mysqlpp/releases/mysql++-3.2.3.tar.gz 解压 tar -zxvf 进入目录 配置 ./configure --help ./configure --prefix=/local/mysql+...

十六、MySQL授权命令grant的使用方法

MySQL 赋予用户权限命令的简单格式可概括为: grant权限 on数据库对象 to用户 一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。 grantselectontestdb.*tocommon_user@'%'grantinsertontestdb.*tocommon_user@'%'grantupd...

mysql自定义变量

mysql可以实现自定义变量,使用方式非常简单,代码如下: SELECT @i:=@i + 1 // 查询变量,值+1 FROM(SELECT @i:=0) i // 声明变量,初始值为0 如果有多条数据,那么这个变量就会按照顺序1,2,3,4,5...拼接到每条数据上,也就实现了增加一个自定义变量。我们可以用它来做排行等功能...

最新文章