Install JDK, Tomcat, and MySQL basic software in Linux.

Source: Internet
Author: User

Install JDK, Tomcat, and MySQL basic software in Linux.

1. Install JDK

After Centos6.5 is installed, OpenJDK is installed by default for Base Server. You must first Delete OpenJDK.

1.1 view the previous jdk

Check whether openjdk has been installed before.

If you are not a root user, you need to switch to the root user (su-root)

Command: rpm-qa | grep java

It is shown as follows: (If yes, uninstall it. If no, It is unnecessary.) Note that the version may be different. The actual operation prevails.

[Root @ HYJ201802/] # rpm-qa | grep java

Tzdata-java-2013g-1.el6.noarch

Java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

Java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

1.2 uninstall openjdk:

(The parameter "tzdata-java-2013j-1.el6.noarch" is the result shown in the above view, stick in on the line, if you show different, please copy the results you have queried)

Rpm-e -- nodeps tzdata-java-2013g-1.el6.noarch

Rpm-e -- nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

Rpm-e -- nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

1.3 install jdk

(1) switch to the root user and enter the usr Directory: cd/usr

(2) create a java Folder: mkdir myapp In the usr directory. After Entering myapp, create a java folder.

(3)、copy or upload jdk-7u71-linux-x64.tar.gz to the java directory (you can also use a tool)

(4) Go to the/usr/java Folder: cd/usr/myapp/java/

(5),, “jdk-7u71-linux-x64.tar.gz "indicates the jdk Installation File Uploaded for you.

Chmod 755 jdk-7u71-linux-x64.tar.gz

(6) decompress: tar-zxvf jdk-7u71-linux-x64.tar.gz

(7) Configure Environment Variables

Vi/etc/profile

Add the following content:

Export JAVA_HOME =/usr/myapp/java/jdk1.7.0 _ 71

Export PATH = $ PATH: $ JAVA_HOME/bin

Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar

Export JAVA_HOME PATH CLASSPATH

(8) recompile Environment Variables

Source/etc/profile

Ii. install tomcat

Install Tomcat

1. Enter the tomcat compressed file directory: cd/usr/local/myapp/

2. Unzip tomcat compressed file: tar-zxvf apache-tomcat-7.0.57.tar.gz

3. Disable the firewall (permanent, restart required): chkconfig iptables off

4. Restart the machine: reboot

Note: Only port 8080 required for tomcat can be opened.

/Sbin/iptables-I INPUT-p tcp-dport 8080-j ACCEPT

/Etc/rc. d/init. d/iptables save

/Etc/init. d/iptables status

5. start tomcat:

Go to the bin directory of tomcat: cd/usr/local/myapp/apache-tomcat-7.0.57/bin/

Start tomcat web server:./startup. sh

Access: 192.168.56.101: 8080

6. Stop tomcat:./shutdown. sh

7. View tomcat log information:

Tail-200f/usr/local/myapp/apache-tomcat-7.0.57/logs/catalina. out

200 indicates the last number of lines displayed

You can also run the combined command to start and view logs:

Enter the bin directory of tomcat

./Startup. sh & tail-200f ../logs/catalina. out

Set tomcat startup

Add

Export JAVA_HOME =/usr/java/jdk1.7.0 _ 71

/Usr/local/myapp/apache-tomcat-7.0.57/bin/startup. sh start

Iii. Install MYSQL

1. check whether there is any built-in MySql

View: rpm-qa | grep mysql

2. uninstall MySql

Delete: Option displayed in rpm-e-nodeps

Rpm-e -- nodeps mysql-libs-5.1.71-1.el6.x86_64

3. Extract

Go to the MySql Directory: cd/usr/local/myapp/

Decompress the installation package to obtain the installation file:

4. Install the server

Modify permissions: chmod 777 MySQL-server-5.6.34-1.rhel5.x86_64.rpm

Run the: rpm-ivh MySQL-server-5.6.34-1.rhel5.x86_64.rpm-nodeps-force

Note:-nodeps-force indicates that the dependency is not checked.

5. Install the client: client

Modify permissions: chmod 777 MySQL-client-5.6.34-1.rhel5.x86_64.rpm

Run the: rpm-ivh MySQL-client-5.6.34-1.rhel5.x86_64.rpm-nodeps-force

6. Start and close mysql

Start mysql: service mysql start

Disable mysql: service mysql stop

Restart mysql: service mysql restart

7. Add a password

/Usr/bin/mysqladmin-u root password '123'

Error 1:

If the password is 5.6 installed, a random password is generated:

1) enter the file to view the password

Vi/root/. mysql_secret

2) use this password to log on to mysql

Mysql-uroot-p Password

3) change the password

Set password = PASSWORD ('20140901 ');

Error 2:

/Usr/bin/mysqladmin: connect to server at 'localhost' failed

Error: 'Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2 )'

Check that mysqld is running and that the socket: '/var/lib/mysql. sock' exists!

It may be that the mysql service fails to be started, or the mysql service is not started.

Ps-ef | grep mysql check whether a process exists. If not, restart the mysql service.

If any, use the kill-9 process id to kill the mysql process and restart it.

8. Modify the mysql encoding table (there will be a short garbled code before modification)

Shutting down MySQL. [???]

Starting MySQL. [???]

1) check whether the my. cnf file exists in/etc. If yes, delete it.

2) upload my. cnf to/etc in the pre-Course Materials

3) restart the mysql Service

Service mysql restart

4) log on to mysql and view the encoding table.

Log on to mysql first:

Mysql-uroot-p123

View the encoding table:

Show variables like "% char % ";

5.5 students:

1) switch to the mysql directory:

Cd/usr/share/mysql

2) Copy my-small.cnf to/etc/my. cnf

Cp my-small.cnf/etc/my. cnf

3) modify my. cnf and add some content:

[Client] Add: default-character-set = utf8

[Mysqld] Add: character_set_server = utf8

9. set to allow remote connection to mysql

An error occurred when trying to connect remotely:

(1) Enter mysql:

Mysql-u root-p

(2) Use the mysql database:

Use mysql;

(3) view the user table:

SELECT Host, User FROM user;

(4) Authorized users:

Grant all privileges on. to root @ '%' identified by '20140901 ';

(5) force refresh permission:

Flush privileges;

10. Configure MySQL auto-start (optional)

1) Add to System Service:

Chkconfig-add mysql

2) automatic start:

Chkconfig mysql on

3) query list:

Chkconfig

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.