Java environment and Tomcat deployment process and MySQL simple modification on the CentOS server

Source: Internet
Author: User
Tags mysql code centos server iptables mysql command line

This document records the modification of the Java, Tomcat deployment, and MySQL database for the Olds Web site after the completion of the CentOS installation, and the red part is the actual operation process.

Initial conditions: CentOS installation Complete (x86 desktop version 5.5), MySQL installation is complete.

Basic knowledge: The CentOS terminal will be used (the first # symbol in the command below is the default terminal command line prompt and does not require actual input).

One, Java installation

1. CentOS comes with openjdk, generally do not use this, need to uninstall.

To view the Java version with the command java-version, the following information is available:

Javaversion "1.6.0"

OpenJDK Runtime Environment (BUILD1.6.0-B09)

OpenJDK 64-bit Server VM (build 1.6.0-b09, Mixed mode)

Then use the command Rpm-qa | grep Java View installation package

The following information is displayed:

java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

Unloading:

Rpm-e--nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

RPM-E--nodeps Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

Note that the middle of the el5 is the letter L, not the number 1

There are some other commands.

Rpm-qa | grep GCJ

Rpm-qa | grep JDK

If you can't find Openjdksource, then you can uninstall it.

Yum-y Remove javajava-1.4.2-gcj-compat-1.4.2.0-40jpp.115

Yum-y Remove Javajava-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

2. Copy the downloaded Java bin installation file (my Jdk-6u45-linux-i586-rpm.bin) to the desired place and I put it in the/usr/java.

In the desktop environment, double-clicking will automatically unzip.

Input in command line environment

# chmod 777jdk-1_5_0_14-linux-i586-rpm.bin

#./jdk-1_5_0_14-linux-i586-rpm.bin

After the installation is completed in the current directory to generate multiple files and a directory, two shortcuts, we only focus on that directory can be, mine is/jdk1.6.0_45

3. Configure Environment variables

Desktop environment into the/etc directory, and then double-click the profile file, will be automatically opened with the editor Gedit, at the end of the file to add the following:

Export java_home=/usr/java/jdk1.6.0_45

Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export path= $PATH: $JAVA _home/bin

Command-line Environment Enter the following command, and then add the above 3 lines as well.

# Vi/etc/profile

Then make the configuration effective and enter the following on the command line:

# Source/etc/profile

If successful, you can see the following with the Java-version command:

Java Version "1.6.0_45"

Java (TM) SE Runtime Environment (build 1.6.0_45-b06)

Java Hotspot (TM) Server VM (build 20.45-b01,mixed mode)

II. TOMCAT Installation

1. I downloaded the version is apache-tomcat-7.0.61.tar.gz, in the desktop environment can be directly double-click Open (and Windows decompression similar), put the folder inside the desired directory, I put in/usr.

In the home folder (apache-tomcat-7.0.61) There are some folders such as Bin, but also have to build a logs folder, otherwise it will be reported can not touch errors.

2. Add a firewall record for the Tomcat service to facilitate extranet access.

The default Tomcat port is 8080, so add port 8080 to the firewall exception.

Desktop environment into the/etc/sysconfig directory, double-click iptables Open With Editor, add a record

-A rh-firewall-l-input-p tcp-m state--state new-m TCP--dport 8080-j ACCEPT

This is inconsistent with other information on the Web because the online information is not successful on my computer. Added in the end of the file may be problematic, but not sure, I put in other similar records together.

The command line environment then enters # VI +/etc/sysconfig/iptables and then adds the record.

Enter # service iptables restart in terminal to restart the firewall.

3. Now you can manually start Tomcat, desktop environment into the/usr/apache-tomcat-7.0.61/bin directory, and then double-click Startup.sh, in the popup screen click Run. After a while, you can visit the website through localhost:8080. In normal words, a tomcat-marked cat appears.

If the logs directory is not built in the first step, then the site cannot be accessed successfully, but Tomcat will not be able to make an error in the desktop environment. If you start tomcat with the command line, you can see the error.

command line Environment Input #/USR/APACHE-TOMCAT-7.0.61/BIN/STARTUP.SH launches Tomcat.

Third, MySQL database modification

1. Go to MySQL command line

Start the terminal, enter # Mysql-u Root-p, according to the prompt to enter the password and then enter, the terminal prompt will become mysql>, indicating that it has entered the MySQL command line mode.

2. Add a field to a table

mysql> show databases;

mysql> use database001;

Mysql> Show tables;

Mysql> ALTER TABLE table001 add column IP varchar (255);

3. Add an index to 3 fields in a table

Mysql> ALTER TABLE table002 add index index1 (JH);

Mysql> ALTER TABLE table002 Add index Index2 (CSRQ);

Mysql> ALTER TABLE table002 Add index index3 (CSSJ);

4. Modify the MySQL encoding to UTF8

Because of some cases in Chinese garbled, so the MySQL server, client, connection, such as unified set to UTF8.

First, use the following command to view the MySQL code

Mysql> Show variables like ' character% ';

This may be the result:

+---------------------------+--------------------------------------------------------+

| variable_name | Value |

+---------------------------+--------------------------------------------------------+

| character_set_client | Latin1 |

| character_set_connection | Latin1 |

| Character_set_database | UTF8 |

| Character_set_filesystem | binary |

| Character_set_results | Latin1 |

| Character_set_server | Latin1 |

| Character_set_system | Latin1 |

| Character_sets_dir | /usr/share/mysql/charsets/|

+--------------------------+---------------------------------------------------------+

You can see that many of the settings are Latin and we need to change all to UTF8. Open the/etc/my.cnf file, modify it, and modify it as follows:

[Mysqld]

Default-character-set = UTF8 #新增

Character_set_server=utf8 #新增

init_connect= ' SET NAMES UTF8 '

Datadir=/var/lib/mysql

Socket=/var/lib/mysql/mysql.sock

User=mysql

Symbolic-links=0

[Mysqld_safe]

Default-character-set = UTF8 #新增

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid

[Client]

Default-character-set = UTF8 #新增

[Mysql.server]

Default-character-set = UTF8 #新增

[MySQL]

Default-character-set = UTF8 #新增

Then save the shutdown and use the command #service mysqld restart to restart MySQL.

"Source Download"

Java environment and Tomcat deployment process and MySQL simple modification on the CentOS server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.