The java environment and tomcat deployment process on the centos server and the simple modification of mysql, and the simple modification of centos

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

The java environment and tomcat deployment process on the centos server and the simple modification of mysql, and the simple modification of centos

This document describes how to deploy java and tomcat and modify the mysql database of the olds website system after centos is installed. The red part indicates the actual operation process.

Prerequisites: centos is installed (x86 desktop version 5.5) and mysql is installed.

Basic knowledge: The centos terminal is used (the # symbol at the top of the command below is the default terminal command line prompt, which does not require actual input ).

I. JAVA installation

1. centos comes with OPENJDK, which is generally not used and needs to be uninstalled.

Run the java-version command to view the java version. The following information is displayed:

Javaversion "1.6.0"

OpenJDK Runtime Environment (build1.6.0-b09)

OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)

Run the command rpm-qa | grep java to view the 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

Uninstall:

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 above el5 is in the middle of the letter l, not the number 1

There are other commands

Rpm-qa | grep gcj

Rpm-qa | grep jdk

If openjdksource cannot be found, you can uninstall it like this.

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 location and I put it in/usr/java.

Double-click in the desktop environment to automatically decompress the package.

Enter

# Chmod 777jdk-rj5_0_14-linux-i586-rpm.bin

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

After the installation is complete, multiple files, one directory, and two shortcuts will be generated in the current directory. We only need to pay attention to that directory. my options are/jdk1.6.0 _ 45.

3. Configure Environment Variables

In the desktop environment, go to the/etc directory and double-click the profile file. The editor gedit is automatically used to open the file. Add the following content at the end of the file:

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

In the command line environment, enter the following command and then add the preceding three lines.

# Vi/etc/profile

Then, make the configuration take effect and enter the following content in the command line:

# Source/etc/profile

If it succeeds, you can see the following content using 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 pipeline 45-b01, mixed mode)

Ii. tomcat installation

1. The downloaded file is apache-tomcat-7.0.61.tar.gz. In the desktop environment, you can double-click it (similar to decompression in windows) and put the folder in the desired directory. I saved it to/usr.

The main folder (apache-tomcat-7.0.61) contains folders such as bin, but you must create a logs folder by yourself. Otherwise, an untouchable error will be reported.

2. Add firewall records for tomcat to facilitate internet access.

The default tomcat port is 8080. Therefore, add port 8080 to the firewall.

Go to the/etc/sysconfig directory in the desktop environment, double-click iptables and open it in the editor to add a record.

-A rh-Firewall-l-INPUT-p tcp-m state -- state NEW-m tcp -- dport 8080-j ACCEPT

This article is inconsistent with other materials written on the Internet, because the information on the Internet is not successful on my computer. There may be problems at the end of the file, but I'm not sure, I put it together with other similar records.

In the command line environment, enter # vi +/etc/sysconfig/iptables and then add the record.

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

3. Now you can start tomcat manually. In the desktop environment, go to the/usr/apache-tomcat-7.0.61/bin directory, double-click startup. sh, and click run on the displayed page. After a while, you can access the website through localhost: 8080. Normally, tomcat's iconic cat appears.

If the logs directory is not created in step 1, the website cannot be accessed successfully, but tomcat will not report errors in the desktop environment. If you start tomcat using the command line, you can see the error message.

Enter #/usr/apache-tomcat-7.0.61/bin/startup. sh in the command line environment to start tomcat.

Iii. mysql database Modification

1. Enter the mysql Command Line

Start the terminal, enter # mysql-u root-p, enter the password as prompted, and press Enter. The terminal prompt will change to mysql>, indicating that the mysql command line mode has been entered.

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 for the three fields in a table

Mysql> alter table table002 add index index1 (tables );

Mysql> alter table table002 add index index2 (csrq );

Mysql> alter table table002 add index index3 (cssj );

4. Modify mysql encoding to utf8

In some cases, Chinese characters are garbled, so mysql server, client, and connection are set to utf8.

Run the following command to view the mysql encoding:

Mysql> show variables like 'character % ';

The result may be as follows:

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

| 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/|

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

We can see that many of the settings are Latin. We need to change all the settings to utf8. open the/etc/my. cnf file and modify the file. The modification is as follows:

[Mysqld]

Default-character-set = utf8 # Add

Character_set_server = utf8 # Add

Init_connect = 'set NAMES utf8'

Datadir =/var/lib/mysql

Socket =/var/lib/mysql. sock

User = mysql

Symbolic-links = 0

[Mysqld_safe]

Default-character-set = utf8 # Add

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

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

[Client]

Default-character-set = utf8 # Add

[Mysql. server]

Default-character-set = utf8 # Add

[Mysql]

Default-character-set = utf8 # Add

Save and close it. Run the command # service mysqld restart to restart mysql.

[Source code download]

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.