下载链接
tomcat7.0.77下载
JDK1.7Linux64位下载
JDK安装和配置
1.在/usr/目录下创建java目录
[root@localhost ~]# mkdir/usr/java
[root@localhost ~]# cd /usr/java
2.下载jdk,然后解压(本文提供jdk,tomcat百度网盘下载链接)
[root@localhost java]# curl -O http://download.Oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz
[root@localhost java]# tar -zxvf jdk-7u79-linux-x64.tar.gz
3.设置环境变量
[root@localhost java]# vi /etc/profile
在profile中添加如下内容:
set java environment
JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.: JAVAHOME/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
此处若配置失败导致linux命令无法正常使用
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin
可使命令恢复赶紧回复profile文件
4.验证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)
Tomcat配置
http://www.linuxidc.com/Linux/2015-08/122241.htm
安装说明
安装环境:CentOS-7.0.1406
安装方式:源码安装
软件:apache-tomcat-7.0.29.tar.gz
下载地址:http://tomcat.apache.org/download-70.cgi
安装前提
安装tomcat
直接上传将apache-tomcat-7.0.29.tar.gz文件上传到/usr/local中执行以下操作:
代码如下:
[root@linuxidc local]# cd /usr/local
[root@linuxidc local]# tar -zxv -f apache-tomcat-7.0.29.tar.gz // 解压压缩包
解压后:
1.修改conf目录下server.xml中的端口号为80(根据自己服务器设置)
2.修改bin目录下,虚拟机内存大小,防止内存溢出
在catalina.sh文件下,
在# OS specific support. $var must be set to either true or false.后面
新增export JAVA_OPTS=”-server -Xms512M -Xmx512M -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true -Djava.awt.headless=true”
启动tomcat
启动tomcat:INFO: Deploying web application directory ……”,启动很慢
找到jdk1.x.x_xx/jre/lib/security/Java.security文件,在文件中找到securerandom.source这个设置项,将其改为:
securerandom.source=file:/dev/./urandom
Mysql5.7安装
下载mysql源安装包shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql源shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep “mysql.-community.”
安装MySQL
yum install mysql-community-server
启动MySQL服务
shell> systemctl start mysqld
查看MySQL的启动状态
shell> systemctl status mysqld
开机启动
shell> systemctl enable mysqld
shell> systemctl daemon-reload
修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
shell> grep ‘temporary password’ /var/log/mysqld.log
shell> mysql -uroot -p
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass4!’;
或者:
mysql> set password for ‘root’@’localhost’=password(‘MyNewPass4!’);
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误
添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,我添加一个新的帐户:
mysql> GRANT ALL PRIVILEGES ON . TO ‘yangxin’@’%’ IDENTIFIED BY ‘Yangxin0917!’ WITH GRANT OPTION;
以上部分个人实践过,以下内容待实践
数据库存emoji 表情问题
mysql> SHOW VARIABLES WHERE Variable_name LIKE ‘character_set_%’ OR Variable_name LIKE ‘collation%’;
+————————–+——————-+
| Variable_name | Value |
+————————–+——————-+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| collation_connection | utf8_general_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+————————–+——————-+
10 rows in set (0.02 sec)
可以看到我的mysql版本是5.7的,utf8mb4有一个使用限制,mysql版本必须是5.5以上,大家需要注意,我目前用的ubuntu系统是16.04的。当前mysql的字符集配置如上表,我们的目的是更改成utf8mb4。
3.找到mysql的配置文件,可用命令
sudo find / -name my.cnf
我的配置文件位置如下,个别的位置有所不同
/etc/mysql/mysql.conf.d/mysqld.cnf
4.修改配置文件
在原文中添加以下内容:
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=’SET NAMES utf8mb4’
原文件中无“[client]”和“[mysql]”,需要手动添加上。
……
Here is entries for some specific programs
The following values assume you have at least 32M ram
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
* Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=’SET NAMES utf8mb4’
#
Instead of skip-networking the default is now to listen only on
……
5.重启mysql服务
sudo service mysql restart
6.查看结果
mysql> SHOW VARIABLES WHERE Variable_name LIKE ‘character_set_%’ OR Variable_name LIKE ‘collation%’;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
Connection id: 3
Current database: * NONE *
+————————–+——————–+
| Variable_name | Value |
+————————–+——————–+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+————————–+——————–+
10 rows in set (0.00 sec)
tomcat7.0.77下载链接:http://pan.baidu.com/s/1miMbkMW
JDK1.7Linux64位:http://pan.baidu.com/s/1eSzmK9s