mil 发表于 2013-8-12 09:54:25

Tomcat7+jdk+mysql安装及项目部署

Tomcat7+jdk+mysql安装及项目部署1. 下载tomcat7、jdk、mysqlapache-tomcat-7.0.42.tar.gzjdk-7u25-linux-i586.gzmysql-5.1.55.tar.gz2. 安装及配置# tar zxvf apache-tomcat-7.0.42.tar.gz -C /usr/src/ ##解压tomcat7# tar zxvf jdk-7u25-linux-i586.gz -C /usr/src/ ##解压jdk# cd /opt# mv /usr/src/apache-tomcat-7.0.42 tomcat7# mv /usr/src/jdk-7u25-linux-i586 jdk# vi /etc/profile ##设置java的环境变量export JAVA_HOME=/opt/jdk/ ##设置jdk变量export PATH=$PATH:$JAVA_HOME/binexport CLASSPATH=$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar# tail -3 /etc/profile ##验证最后三行export JAVA_HOME=/opt/jdk/export PATH=$PATH:$JAVA_HOME/binexport CLASSPATH=$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar## source /etc/profile ##读取文件使变量生效# tar zxvf mysql-5.1.55.tar.gz -C /usr/src ##解压mysql# cd /usr/src/mysql-5.1.55/# ./configure --prefix=/opt/mysql ##配置并指定安装的目录# make &&make install ##编译及安装# cp support-files/my-medium.cnf /etc/my.cnf ##创建mysql的配置文件# cd /opt/mysql/# useradd -u 26 -M -s /sbin/nologin mysql# bin/mysql_install_db --user=mysql ##使用mysql用户初始化数据库
# chown -R root:mysql /opt/mysql# chown -R mysql /opt/mysql/var/优化执行路径、程序库路径:# ln -s /opt/mysql/bin/* /usr/local/bin/# ln -s /opt/mysql/lib/mysql/* /usr/lib/# ln -s /opt/mysql/include/mysql/* /usr/include/添加mysql为系统服务:# cp /usr/src/mysql-5.1.55/support-files/mysql.server /etc/init.d/mysqld# chmod +x /etc/init.d/mysqld#chkconfig --add mysqld ##添加为系统服# /etc/init.d/mysqld start ##启动服务设置mysql的字符集:# vi /etc/my.cnfdefault-character-set=utf8 ##将这一项添加到【msyql】【mysqld】模块中#/etc/init.d/mysqld restart ##重启mysql使用mysql:# mysqladmin -uroot password ‘123123’ ##mysql数据库root的密码为123123# mysqldump -uroot -p123123 --all-databases >mysql.sql ##备份mysql# mysql -uroot -p123123 上传项目:在windows的D盘存放项目文件dc、dc.sql及pscp.exe程序,然后在运行(窗口键+R)中、运行cmd打开命令提示符:C:Usersshenchengfa>d:D:>pscp dc dc.sql root@192.168.8.49:/opt/tomcat7/webapps/导入项目数据:# mysql -uroot –p123123 ##登录mysqlWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 217Server version: 5.1.55-log Source distributionCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL v2 licenseType 'help;' or 'h' for help. Type 'c' to clear the current input statement.mysql> create database dc; ##创项目数据库mysql>quit# mysql -uroot -p123123 --databases dc< dc.sql ##导入项目数据# service mysqld restart ##重启mysql修改项目数据库密码:此处视特定项目而定、与研发人员沟通确认# vi /opt/tomcat7/webapps/dc/WEB-INF/web.xml
This is the description of my J2EE componentThis is the display name of my J2EE componentControlServeletaction.ControlServelet
driverStringcom.mysql.jdbc.Driver

urlStringjdbc:mysql://127.0.0.1:3306/dc

usernameroot

password123123

excelpath/var/lib/tomcat6/webapps/dc/biao/

jsppath/var/lib/tomcat6/webapps/dc/
1
# /opt/tomcat7/bin ##重启tomcat# ./shutdown.sh ##停止tomcatUsing CATALINA_BASE: /opt/tomcat7Using CATALINA_HOME: /opt/tomcat7Using CATALINA_TMPDIR: /opt/tomcat7/tempUsing JRE_HOME: /opt/jdk/Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar# ./startup.sh ##启动tomcatUsing CATALINA_BASE: /opt/tomcat7Using CATALINA_HOME: /opt/tomcat7Using CATALINA_TMPDIR: /opt/tomcat7/tempUsing JRE_HOME: /opt/jdk/Using CLASSPATH: /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar4. 测试验证在浏览器中访问测试,访问时注意iptables、及selinux的限制,可以将其关闭,等测试无误后在做调整# setenforce 0 ##设置selinux的状态为允许、默认是1为强制限制# /etc/init.d/iptables stop ##关闭防火墙Tomcat默认使用8080端口、但是上文已经改为80端口,直接输入ip加项目名即可,如图:

kinght2008 发表于 2013-8-13 09:30:09

走自己的路,让别人打车去吧。

bgey 发表于 2013-8-13 17:18:56

此地禁止大小便,违者没收工具。

515439429 发表于 2013-8-14 00:00:46

看尽天下A片,心中自然无码~

yllplay 发表于 2013-8-14 03:36:01

你的丑和你的脸没有关系。。。。。。

378 发表于 2013-8-14 04:20:38

走自己的路,让别人打车去吧。

beebe_3 发表于 2013-8-14 05:56:44

看帖回帖是美德!:lol
页: [1]
查看完整版本: Tomcat7+jdk+mysql安装及项目部署