Home Database Mysql Tutorial centos下tomcat+mysql的配置和项目部署_MySQL

centos下tomcat+mysql的配置和项目部署_MySQL

Jun 01, 2016 pm 01:11 PM

CentOSTomcat

TOMCAT服务器的配置

1. jre的安装

1.1 查看centos中原来自带的JDK并卸载

[root@balakids home]# java -version|grep gcj [root@balakids home]# yum -y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Copy after login

1.2 复制jre-6u38-linux-x64-rpm.bin到目录/opt中

cp /home/jre-6u38-linux-x64-rpm.bin /opt/.
Copy after login

1.3 为该文件赋予执行权限

chmod +x /opt/jre-6u38-linux-x64-rpm.bin
Copy after login

1.4 执行此文件即安装jre

[root@balakids jre]# ./jre-6u38-linux-x64-rpm.bin  Unpacking... Checksumming... Extracting... UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).  inflating: jre-6u38-linux-amd64.rpm  Preparing...                ########################################### [100%]    1:jre                    ########################################### [100%] Unpacking JAR files...     rt.jar...     jsse.jar...     charsets.jar...     localedata.jar...     plugin.jar...     javaws.jar...     deploy.jar...   Done.
Copy after login

1.5 查看java版本

[root@balakids jre]# java -versionjava version "1.6.0_38" Java(TM) SE Runtime Environment (build 1.6.0_38-b05) Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)
Copy after login

2 tomcat的配置

2.1 解压tomcat的压缩包并移动到想要放置的位置

[root@balakids home]# tar -xvf apache-tomcat-6.0.39.tar.gz [root@balakids home]# mv apache-tomcat-6.0.39 /usr/local/tomcat
Copy after login

2.2 复制tomcat的启动脚本

[root@balakids conf]# cd /usr/local/tomcat/bin [root@balakids bin]# cp catalina.sh /etc/init.d/tomcatd[root@balakids bin]# chmod +x /etc/init.d/tomcatd
Copy after login

2.3 更改tomcat的启动脚本,指向JRE和TOMCAT的目录

[root@balakids ROOT]# rpm -ql jre    //查询JRE安装的位置[root@balakids conf]# vim /etc/init.d/tomcatd JRE_HOME=/usr/java/jre1.6.0_38 CATALINA_HOME=/usr/local/tomcat
Copy after login

2.4 为tomcat配置用户管理 //可有可无的操作

[root@balakids conf]# vim /usr/local/tomcat/conf/tomcat-users.xml  <tomcat-users>     <role rolename="manager-gui"/>   <role rolename="admin-gui"/>   <user username="tomcat" password="tomcat" roles="admin-gui,manager-gui"/> </tomcat-users>  [root@balakids conf]# /etc/init.d/tomcatd start
Copy after login

2.5 测试 在浏览器中使用IP进行测试,本机IP:10.10.54.178,端口号为8080

centos下tomcat+mysql的配置和项目部署_MySQL

刚才所配置的用户管理则是访问这个页面中的选项时使用,如下访问status时弹出来的用户登录

centos下tomcat+mysql的配置和项目部署_MySQL

3 安装mysql5.1.50 3.1 安装所需依赖包

//之前先做了yum源

[root@balakids mysql-5.1.50]#yum install gcc-c++ gcc libtermcap-devel.x86_64 -y
Copy after login


3.2 mysql的解压、编译、安装

[root@balakids home]# tar xvf mysql-5.1.50.tar.gz[root@balakids home]# cd mysql-5.1.50 [root@balakids mysql-5.1.50]#./configure --prefix=/usr/local/mysql --datadir=/data/mysql --with-charset=utf8 /--with-extra-charsets=complex / --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock / --with-pthread --enable-assembler --with-mysqld-ldflags=-all-static / --with-client-ldflags=-all-static / --with-plugins=partition,archive,csv,federated,heap,innobase,myisam,myisammrg,innodb_plugin,ndbcluster / --with-mysqld-user=mysql[root@balakids mysql-5.1.50]# make && make install
Copy after login

3.3 创建mysql用户并更改目录所属用户

[root@balakids mysql-5.1.50]# useradd mysql -s /sbin/nologin [root@balakids mysql-5.1.50]# chown mysql.mysql /usr/local/mysql/ -R [root@balakids mysql-5.1.50]# chown mysql.mysql /data/  -R
Copy after login

3.4 复制配置文件和启动脚本 --在解压缩的包中复制

[root@balakids mysql-5.1.50]# cp support-files/my-large.cnf /etc/my.cnf [root@balakids mysql-5.1.50]# cp support-files/mysql.server /etc/init.d/mysqld [root@balakids mysql-5.1.50]# chmod +x /etc/init.d/mysqld  //更改配置文件,加入datadir的目录 Vim /etc/my.cnf  [mysqld]datadir=/data/mysql
Copy after login

3.4 初始化数据库

[root@balakids mysql-5.1.50]# /usr/local/mysql/bin/mysql_install_db --user=mysql
Copy after login

如果再初始化的时候指定basedir的目录则会报以下错误: FATAL ERROR: Could not find errmsg.sys

3.5 添加环境变量

[root@balakids mysql-5.1.50]# vim /etc/profile.d/mysql.sh PATH=$PATH:/usr/local/mysql/bin [root@balakids mysql-5.1.50]# source /etc/profile.d/mysql.sh
Copy after login

4 balakids项目部署,本机IP:10.10.54.178

把项目复制到tomcat下的webapps下

4.1 对mysql数据库的更改 Balakids项目登录数据库用户为root,密码为mysql,即依此更改数据库

[root@balakids lib]# mysqladmin -uroot -p123456 password 'mysql' mysql> update user set host='10.10.54.178' where host='localhost';
Copy after login

//当然可以自己重新创建用户,但是要注意的时不要忘了对项目中的一些文件进行更改,下面介绍项目中所要配置的内容 4.2 tomcat配置文件的更改 更改tomcat的配置文件

[root@balakids tomcat]# vim /usr/local/tomcat/conf/server.xml
Copy after login
<Engine name="Catalina" defaultHost="10.10.54.178"><Host name="10.10.54.178"  appBase="webapps"             unpackWARs="true" autoDeploy="true"             xmlValidation="false" xmlNamespaceAware="false">
Copy after login

//上面配置文件中的defaultHost默认为localhost,更改为本机IP

4.3 项目中需注意的文件 项目中最值得注意的文件莫过于对数据库的连接了也就时context.xml

绝对路径: /usr/local/tomcat/webapps/balakids/META-INF/context.xml

其内容为:

<?xml version="1.0" encoding="UTF-8"?><!-- 配置数据源 --> <Context path="/balakids" reloadable="true">         <Resource name="balakids/jdbc"         auth="Container"         type="javax.sql.DataSource"          username="root"                //用户名        password="mysql"                //密码         driverClassName="com.mysql.jdbc.Driver"          url="jdbc:mysql://10.10.54.178:3306/balakids"  //连接数据库     maxActive="8"     maxIdle="4"/><!-- 测试JNDI --> <Environment name="onlineexam_jndi" value="Hello JNDI" type="java.lang.String"/></Context>
Copy after login


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

How do you drop a table in MySQL using the DROP TABLE statement? How do you drop a table in MySQL using the DROP TABLE statement? Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Apr 02, 2025 pm 07:05 PM

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

How do you create indexes on JSON columns? How do you create indexes on JSON columns? Mar 21, 2025 pm 12:13 PM

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

See all articles