JDK的配置
- 更新软件
yum update
- 查看是否安装Java
java -version
如果出现以下图片,说明没有安装java的JDK
-
查看内置是否存在JDK
rpm -qa | grep jdk
#卸载内置的JDK
yum remove java-1.6.0-openjdk
yum remove java-1.7.0-openjdk
首先在oracle网站下载jdk1.8的文件tar.gz的压缩包
这是推荐的网址
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
这边可以使用winscp这个软件上传到服务器的后台
将tar.gz 文件上传上去
解压安装 tar.gz
mkdir /jdk
mkdir /jdk
chmod 777 /jdk
tar -zxvf jdk-8u91-linux-x64.tar.gz -C /jdk
备注:如何你想要自己创建文件夹,请用绝对路径解压
- 配置环境变量
# 修改配置文件
vi /etc/profile
# 在export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL下添加
export JAVA_HOME=/jdk/jdk1.8.0_144
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
# 刷新配置文件
source /etc/profile
Tomcat的安装
- 使用离线安装,因为国内的下载速度比较慢。
下载网址
https://tomcat.apache.org/download-80.cgi
也可以用wegt离线下载
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36.tar.gz
- 同上面的jdk ,解压
mkdir /tomcat
chmod 777 /tomcat //获得文件的最高权限
tar -zxvf apache-tomcat-8.0.36.tar.gz -C /tomcat
启动服务
cd /tomcat/apache-tomcat-8.0.36/bin/
./startup.sh
进入防火墙配置
vi /etc/sysconfig/iptables
配置8080端口
/sbin/iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
/etc/rc.d/init.d/iptables save
这边 vi 是编辑 esc+:wq保存(注意冒号是需要的)
MySQL5.1的配置,如果需要5.7版本的。可以百度一下哦
1.使用yum命令安装mysql
[root@bogon ~]# yum -y install mysql-server
2.设置开机启动
[root@bogon ~]# chkconfig mysqld on
3.启动MySQL服务
[root@bogon ~]# service mysqld start
查询用户的密码,都为空,用下面的命令设置root的密码为root
mysql> set password for root@localhost=password('root');
mysql> exit
4.1修改mysql的默认引擎为InnoDB
[root@bogon ~]# service mysqld stop
4.2 修改/etc/my.cnf
[mysqld] 后加入
default-storage-engine=InnoDB
9.3 启动mysql
[root@bogon etc]# service mysqld start
Starting mysqld: [ OK ]
10.CentOS6.5开放mysql端口3306
CentOS6.5默认是不开放端口的,如果要让外部的系统访问CentOS6.5上的mysql,必须开放mysql的端口3306
5.1 修改/etc/sysconfig/iptables
添加下面一行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
6.重启防火墙
[root@bogon etc]# service iptables restart
如果出现mysql无法连接的时候,一定是没有授权以下提供两种方案:
方法一:实现远程连接(授权法)
mysql> use mysql;
Database changed
mysql> grant all privileges on *.* to root@'%' identified by "root";
mysql> select host,user,password from user;
方法二:实现远程连接(改表法)
将host字段的值改为%就表示在任何客户端机器上能以root用户登录到mysql服务器,建议在开发时设为%。
mysql> use mysql;
Database changed
mysql> update user set host = '%' where user = 'root';
这时,root将权限改为ALL PRIVILEGES;
这样在远端就可以通过root用户访问Mysql.
注意配置安全组哦,在腾讯云上面的开放3306 :8080:23:3389的端口
mysql5.6或者5.7的配置
- 创建MySQL用户
#useradd mysql
#passwd mysql
#chmod u+w /etc/sudoers
#vi /etc/sudoers
mysql ALL=(ALL) ALL
- 安装仓库
要使用yum 安装mysql,要使用mysql的yum仓库,先从官网下载适合你系统的仓库
http://dev.mysql.com/downloads/repo/yum/
然后安装一下这个仓库列表
wget http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm
rpm -ivh mysql-community-release-el6-8.noarch.rpm
或:
# yum install http://repo.mysql.com//mysql57-community-release-el6-8.noarch.rpm(推荐直接云安装,快多了)
- 选择版本
查看可安装的mysql版本
[mysql@mysql-1 ~]$ yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community MySQL Connectors Community 21
mysql-tools-community MySQL Tools Community 35
mysql57-community MySQL 5.7 Community Server 82
- 如果我们要选择版本,可以先执行下面这个命令查看一下有哪些版本
选择版本,启用5.6版本的,禁用5.7版本子仓库
[mysql@mysql-1 ~]$ sudo yum-config-manager --enable mysql56-community
[mysql@mysql-1 ~]$ sudo yum-config-manager --disable mysql57-community
或者 编辑/etc/yum.repos.d/mysql-community.repo文件
enabled=0 表示禁用
比如要安装5.7版本的mysql,要确定5.6的enabled=0,5.7的enabled=1,一次保证只启用一个子仓库
- 查看可安装的mysql版本只有5.6的三个了。如果是5.7上面的配置修改一下,自行百度吧
[mysql@mysql-1 ~]$ yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community MySQL Connectors Community 21
mysql-tools-community MySQL Tools Community 35
mysql56-community MySQL 5.6 Community Server 248
安装
[mysql@mysql-1 ~]$ sudo yum install mysql-community-server
- 查看当前的MySQL版本
[root@mysql-1 mysql]# mysql -V
启动MySql
[root@mysql-1 mysql]# service mysqld strat
- 安全组的配置
[root@mysql-1 mysql]# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): ----输入root密码(默认为空):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y ----是否要修改root密码:
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] n
... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
[root@mysql-1 mysql]#
最后
[root@mysql-1 mysql]# service mysqld status
mysqld (pid 3097) is running