Centos部署Tomcat,Mysql,Jdk

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语句执行的最大长度

执行vi /etc/my.cnf命令

在[mysqld]最后增加:

default-character-set=utf8

character-set-server = utf8

init_connect=’set names utf8′

max_allowed_packet = 50M

wait_timeout=27594000

 

重启mysql命令: service mysqld restart

进入到mysql查看超时时间:show global variables like ‘wait_timeout’;

 

7. 进入mysql中查看当前编码

mysql>show variables like ‘%character%’;

 

8.设置访问权限和密码

mysql>grant all privileges on *.* to ‘root’@’%’ identified by ‘admin’;

mysql>grant all privileges on *.* to ‘root’@’localhost’ identified by ‘admin’;

mysql>flush privileges;

 

9.查看当前已经设置的访问权限状态

mysql>select user,host,password  from mysql.user;

 

10. 重启mysql服务

service mysqld restart 或者 /etc/init.d/mysqld restart 

 

11.删除mysql(安装出错时再执行)

yum remove mysql mysql-server mysql-libs compat-mysql51

rm -rf /var/lib/mysql

rm /etc/my.cnf

 

12.查看是否存在mysql(安装出错时再执行)

rpm -qa|grep mysql  //有的话继续删除

rpm -ql mysql       //查看文件位置

 

  1. 注:重启服务器:reboot

 

 

 

八、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.修改环境变量:

[root@localhost java]# vi ~/.bashrc

export JAVA_HOME=/opt/java/jdk1.7.0_71

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH=${JAVA_HOME}/bin:$PATH

如下:

6.使配置的环境变量生效

[root@localhost java]# source ~/.bashrc

 

7.使这个JDK为系统默认JDK对于多jdk环境比较有用(如果环境是新的无需执行下面语句)

[root@localhost java]# update-alternatives –install /usr/bin/java java /opt/java/jdk1.7.0_71/bin/java 300

[root@localhost java]# update-alternatives –install /usr/bin/javac javac /opt/java/jdk1.7.0_71/bin/javac 300

[root@localhost java]# update-alternatives –install /usr/bin/jar jar /opt/java/jdk1.7.0_71/bin/jar 300

[root@localhost java]# update-alternatives –install /usr/bin/javah javah /opt/java/jdk1.7.0_71/bin/javah 300

[root@localhost java]# update-alternatives –install /usr/bin/javap javap /opt/java/jdk1.7.0_71/bin/javap 300

 

8.查看安装的jdk是否好用

java -version

javac -version

输入两条命令后,显示的版本信息一致,则说明已经成功

 

 

九、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

 

 

About hackgoo 110 Articles
渗透测试人员,信息安全维护 主要技能web安全,linux运维 站在巨人的肩膀上,在学习中进步,在进步中学习,低调求生存 极客谷保留所有权利,转载请注明出处

Be the first to comment

Leave a Reply

Your email address will not be published.


*