Linux部署Tomcat、JDK、MySQL(详细步骤)
一、Tomcat安装
1.将tomcat安装包apache-tomcat-7.0.57-windows-x64.zip在本地解压后放到/usr/local目录
2.修改解压后的目录的权限
[root@localhost local]# chmod -cfvR 777 apache-tomcat-7.0.57/
3.修改环境变量:
[root@localhost java]# vi ~/.bashrc export CATALINA_HOME=/usr/local/apache-tomcat-7.0.57
使配置的环境变量生效 [root@localhost java]# source ~/.bashrc
如图:
4.启动tomcat命令:
[root@localhost local]# /usr/local/apache-tomcat-7.0.57/bin/startup.sh
显示下面信息表明启动成功:
5. 关闭命令:
[root@localhost local]# /usr/local/apache-tomcat-7.0.57/bin/shutdown.sh
6.修改端口:
Tomcat默认端口为8080,为了防止和ATCTI端口冲突需要改为8090
修改Tomcat目录下的conf/server.xml文件
将<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/> 改为<Connector connectionTimeout="20000" port="8090" protocol="HTTP/1.1" redirectPort="8443"/>
7. 加入系统服务:
将tomcat的系统自启动文件拷贝到/etc/rc.d/init.d/目录 修改权限:chmod 777 /etc/rc.d/init.d/tomcat 执行命令:chkconfig --add tomcat 查看是否加入成功:chkconfig 之后启动和关闭tomcat可以通过以下命令来操作,并且tomcat会开机自动启动
service tomcat start service tomcat stop
===========================================================================>>
二、JDK安装
1.将安装包jdk-7u71-linux-x64.tar.gz拷贝到/opt/java目录
2.将包权限改成777
chmod 777 jdk-7u71-linux-x64.tar.gz
3.解压
[root@localhost java]# tar -xvf jdk-7u71-linux-x64.tar.gz
4.修改解压后的目录的权限
[root@localhost java]# chmod -cfvR 777 jdk1.7.0_71/
5.修改环境变量:
1 [root@localhost java]# vi ~/.bashrc 2 3 export JAVA_HOME=/opt/java/jdk1.7.0_71 4 export JRE_HOME=${JAVA_HOME}/jre 5 export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib 6 export PATH=${JAVA_HOME}/bin:$PATH
如下:
6.使配置的环境变量生效
[root@localhost java]# source ~/.bashrc
7.使这个JDK为系统默认JDK对于多jdk环境比较有用(如果环境是新的无需执行下面语句)
1 [root@localhost java]# update-alternatives --install /usr/bin/java java /opt/java/jdk1.7.0_71/bin/java 300 2 [root@localhost java]# update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.7.0_71/bin/javac 300 3 [root@localhost java]# update-alternatives --install /usr/bin/jar jar /opt/java/jdk1.7.0_71/bin/jar 300 4 [root@localhost java]# update-alternatives --install /usr/bin/javah javah /opt/java/jdk1.7.0_71/bin/javah 300 5 [root@localhost java]# update-alternatives --install /usr/bin/javap javap /opt/java/jdk1.7.0_71/bin/javap 300
8.查看安装的jdk是否好用
1 java -version 2 javac -version
输入两条命令后,显示的版本信息一致,则说明已经成功.
=================================================================================================>>>
三、mysql安装
1.在线安装命令
yum -y install mysql-server
2.装入Service启动服务
/etc/rc.d/init.d/mysqld start 或者service mysqld restart
3. 设置mysql服务开机自启动
chkconfig mysqld on
4.查看mysql开机自启动设置情况
chkconfig --list mysqld (mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off) ← 如果2--5为on的状态就OK
5.查看当前mysql版本信息
mysql --version
6. 修改mysql默认编码和sql语句执行的最大长度
1 执行vi /etc/my.cnf命令 2 在[mysqld]最后增加: 3 default-character-set=utf8 4 character-set-server = utf8 5 init_connect='set names utf8' 6 max_allowed_packet = 50M 7 wait_timeout=27594000
1 重启mysql命令: service mysqld restart 2 进入到mysql查看超时时间:show global variables like 'wait_timeout'
7. 进入mysql中查看当前编码
mysql>show variables like '%character%';
8. 设置访问权限和密码
1 mysql> grant all privileges on *.* to 'root'@'%' identified by 'admin'; 2 mysql> grant all privileges on *.* to 'root'@'localhost' identified by 'admin'; 3 mysql> flush privileges;
9.查看当前已经设置的访问权限状态
mysql> select user,host,password from mysql.user;
10. 重启mysql服务
service mysqld restart 或者 /etc/init.d/mysqld restart
11.删除mysql(安装出错时再执行)
1 yum remove mysql mysql-server mysql-libs compat-mysql51 2 rm -rf /var/lib/mysql 3 rm /etc/my.cnf
12.查看是否存在mysql(安装出错时再执行)
1 rpm -qa|grep mysql //有的话继续删除 2 rpm -ql mysql //查看文件位置
13. 注:重启服务器:reboot
分享几个工具给大家
JDK8 64位windows系统:下载
JDK8 64位Linux系统:下载
JDK7 32位windows系统:下载
JDK7 64位windows系统:下载
数据库(官网下载)
MySQL5.5版本Windows32位:下载
MySQL5.5版本Windows64位:下载
MySQL5.5版本Linux:下载
Tomcat
apache-tomcat-9.0.0.M9-windows-x86:下载
apache-tomcat-9.0.0.M9-windows-x64:下载
apache-tomcat-8.5.4-windows-x64:下载
apache-tomcat-8.5.4-windows-x86:下载
apache-tomcat-7.0.70-windows-x86:下载
apache-tomcat-7.0.70-windows-x64:下载