Jdk+apache+tomcat+mysql configuration Let's learn together.

Source: Internet
Author: User
Tags chmod iptables

Configuration jdk1.8+apache2.4+tomcat8.0+mysql5.1, the information on the Internet is very complex, spend a few days to configure success, summary records.

Operating system: CentOS6.5

Download the latest version of the Software in advance:

Apache-tomcat-8.0.14.tar.gz

Apr-1.5.1.tar.gz

Apr-util-1.5.4.tar.gz

Httpd-2.4.10.tar.gz

jdk-8u20-linux-x64.rpm

Pcre-8.36.tar.gz

Tomcat-connectors-1.2.40-src.tar.gz

(i) uninstalling the JDK under CentOS

First, log in as root account

Second, view the JDK that the system has installed

[Email protected]]# Rpm-qa|grep JDK

[Email protected]]# rpm-qa|grep java

Jdk-1.6.0_22-fcs

Third, uninstall the JDK

[Email protected]]# rpm-e--nodeps Jdk-1.6.0_22-fcs

/var/tmp/rpm-tmp.17570:line 466:/usr/java/jdk1.6.0_22/bin/java:no such file or directory

IV. Uninstall again, indicating that the JDK has been removed and the system does not have a JDK installed

[Email protected]]# rpm-e--nodeps Jdk-1.6.0_22-fcs

Error:package Jdk-1.6.0_22-fcs is not installed

The following is the uninstallation of Java-related files, the command usage is the same as above, if you need to unload more than one file at a time, directly separated by a space, such as: Rpm-e--nodeps sun-javadb-javadoc-10.5.3-0.2 sun-javadb-common-10.5.3-0.2

[Email protected]]# Rpm-qa|grep JDK

[Email protected]]# rpm-qa|grep java

sun-javadb-core-10.5.3-0.2

sun-javadb-demo-10.5.3-0.2

sun-javadb-javadoc-10.5.3-0.2

sun-javadb-common-10.5.3-0.2

sun-javadb-docs-10.5.3-0.2

[Email protected]]# rpm-e--nodeps sun-javadb-core-10.5.3-0.2

[Email protected]]# rpm-qa|grep java

sun-javadb-demo-10.5.3-0.2

sun-javadb-javadoc-10.5.3-0.2

sun-javadb-common-10.5.3-0.2

sun-javadb-docs-10.5.3-0.2

[Email protected]]# rpm-e--nodeps sun-javadb-demo-10.5.3-0.2

[Email protected]]# rpm-qa|grep java

sun-javadb-javadoc-10.5.3-0.2

sun-javadb-common-10.5.3-0.2

sun-javadb-docs-10.5.3-0.2

[Email protected]]# rpm-e--nodeps sun-javadb-javadoc-10.5.3-0.2 sun-javadb-common-10.5.3-0.2

[Email protected]]# rpm-qa|grep java

sun-javadb-docs-10.5.3-0.2

[Email protected]]# rpm-e--nodeps sun-javadb-docs-10.5.3-0.2

All Java-related file deletions are now complete.

(ii) installation of JDK

Rpm–i jdk***

The default installation directory is/usr/java

There are three ways to configure environment variables for the JDK, and here are just a few ways to modify the/etc/profile file.

• Open/etc/profile with a text editor

• At the end of the profile file, add:

    1. Export java_home=/usr/java/jdk1.6.0_31
    2. Export path= $JAVA _home/bin: $PATH
    3. Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

After adding, reboot, enter the following two commands in the terminal to see if the success

    1. [Email protected] ~]# java-version
    2. [Email protected] ~]# javac-version
(iii) installation of Tomcat

1) #tar-ZXVF apache-tomcat-6.0.35.tar.gz;//Decompression

2) #cp-R apache-tomcat-6.0.35/usr/tomcat6;//copy apache-tomcat-6.0.35 to/usr and rename to Tomcat6

3)/usr/tomcat6/bin/startup.sh; Start Tomcat

Show

    1. Using catalina_base:/usr/tomcat6
    2. Using Catalina_home:/usr/tomcat6
    3. Using Catalina_tmpdir:/usr/tomcat6/temp
    4. Using Jre_home:/usr/java/jdk1.6.0_31
    5. Using CLASSPATH:/usr/tomcat6/bin/bootstrap.jar

To this tomcat has been installed, now using the browser to access http://localhost:8080, the Tomcat default page appears, indicating that the installation was successful.

Install Linux in WMware after installing the database, JDK and Tomcat to start the service, the virtual machine can access, but the host is not accessible, but at the same time between the host and the virtual machine can be ping, online access to data, the solution is to shut down the virtual machine Firewall service. Desktop--management--security level and firewall, set the firewall to: Disable. or log in with root, execute
Service Iptables stop--stop
Service iptables Start--Start

Reboot


However, in real-world applications, shutting down the firewall reduces the security of the server and cannot shut down the firewall.
If you telnet to the 8080 window of the virtual machine under the host's DOS window, it will fail, so you can determine that there is a problem with the virtual machine's 8080 window, and it should be blocked by the firewall. So modify the firewall settings.

Modify the Linux system firewall configuration need to modify/etc/sysconfig/iptables this file, if you want to open which port, add a bar inside
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport8080-j ACCEPT
Yes, where 8080 is the port number to open, and then restart the Linux Firewall service,
/etc/init.d/iptables restart.

Method Two: Register Tomcat as a system service

1, first copy the catalina.sh command to the/ETC/INIT.D directory, renamed Tomcat;

2. Use the editor to open the Tomcat file and add two lines of text under the first line #!/bin/sh, as follows:

# chkconfig:2345 10 90

# Description:tomcat Service

Then add:

catalina_home=/usr/local/apache-tomcat-7.0.11

Java_home=/usr/local/jdk1.6.0_24

Save Close

3. chmod 777 Tomcat

4. Then register the service

# chkconfig--add Tomcat

#chkconfig Tomcat on

Everything OK, start the service

# service Tomcat Start

Reboot, check whether it starts

Check the startup situation

Ps-ef |grep Tomcat

(iv) installation of MySQL

Yum Install Mysql-server

Chmod/tmp

Auto Start

Chkconfig--add mysqld

Chkconfig mysqld on

Change Password

Outside the MySQL system, use the Mysqladmin

# mysqladmin-u root-p Password "test123"

Enter Password: "Enter the original password"

(i) configuration database character set is UTF8

Liunx under:

1. Find the location of the cnf file for MySQL

Find/-iname ' *.cnf '-print

/usr/share/mysql/my-innodb-heavy-4g.cnf

/usr/share/mysql/my-large.cnf

/usr/share/mysql/my-small.cnf

/usr/share/mysql/my-medium.cnf

/usr/share/mysql/my-huge.cnf

/usr/share/texmf/web2c/texmf.cnf

/usr/share/texmf/web2c/mktex.cnf

/usr/share/texmf/web2c/fmtutil.cnf

/usr/share/texmf/tex/xmltex/xmltexfmtutil.cnf

/usr/share/texmf/tex/jadetex/jadefmtutil.cnf

/usr/share/doc/mysql-server-community-5.1.22/my-innodb-heavy-4g.cnf

/usr/share/doc/mysql-server-community-5.1.22/my-large.cnf

/usr/share/doc/mysql-server-community-5.1.22/my-small.cnf

/usr/share/doc/mysql-server-community-5.1.22/my-medium.cnf

/usr/share/doc/mysql-server-community-5.1.22/my-huge.cnf

2. Copy small.cnf to/etc, named MY.CNF

Cp/usr/share/mysql/my-medium.cnf/etc/my.cnf

3. Modify MY.CNF

Vi/etc/my.cnf

Add under [client]

Default-character-set=utf8

Add under [mysqld]

Default-character-set=utf8

4. Restart MySQL

[Email protected] ~]#/etc/rc.d/init.d/mysql restart

(v) installation of Apache

The Apache 2.4.x installation configuration steps are as follows:

First, the preparatory work

Yum-y install gcc gcc-c++ unzip Rpm-build

II. installation of APR and Apr-util

wget http://mirror.bit.edu.cn/apache//apr/apr-1.4.8.tar.gz

wget http://mirror.bit.edu.cn/apache//apr/apr-util-1.5.2.tar.gz

TAR-ZXF apr-1.4.8.tar.gz

CD apr-1.4.8

Mkdir/usr/local/apr

./configure--PREFIX=/USR/LOCAL/APR

Make

Make install

Mkdir/usr/local/apr-util

TAR-ZXF apr-util-1.5.2.tar.gz

CD apr-util-1.5.2

./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr/bin/apr-1-config

Make

Make install

Third, installation Prce

wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz

Unzip Pcre-8.33.zip

CD pcre-8.33

Mkdir/usr/local/pcre

./configure--prefix=/usr/local/pcre--with-apr=/usr/local/apr/bin/apr-1-config

Make

Make install

Iv. installation of Apache HTTPD Server

Mkdir/usr/local/apache

wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.6.tar.gz

Tar zxvf httpd-2.4.6.tar.gz

CD httpd-2.4.6

./configure--prefix=/usr/local/apache--with-pcre=/usr/local/pcre--with-apr=/usr/local/apr--with-apr-util=/usr/ Local/apr-util

Make

Make install

V. Launch of Apache Services

/usr/local/apache/bin/apachectl start

Prompt it works! when accessing http://localhost with a browser

There are two ways to enable Apache to start automatically when the system starts.

Method One: Modify the configuration file

Configuration file path: # vi/etc/rc.d/rc.local

In the/ect/rc.d/rc.local file, add the command to start Apache as follows:

/usr/local/apache/bin/apachectl start

Method Two: Register Apache as a system service "better"

1, first copy the Apachectl command to the/ETC/INIT.D directory, renamed to HTTPD;

2. Use the editor to open the httpd file and add two lines of text under the first line #!/bin/sh, as follows:

# chkconfig:35 70 30

# Description:apache

Save Close

3. Then register the service

# chkconfig--add httpd

Everything OK, start the service

# service httpd Start

#chkconfig httpd on

Reboot, check whether it starts

Where, in the second row of the added three digits, the first indicates that Apache is started at run Level 3 and 5, the second to third is about the start and stop priority configuration, does not matter.

(vi) Integration of Apache, Tomcat

Compile

#wget http://archive. Apacheorg/dist/t ... s-1.2.30-src.tar.gz
#tar zxvf Tomcat-*
#cd Tomcat-*/native
#./configure--with-apxs=/usr/local/Apache/bin/apxs
#make && make Install
Go to Apache modules and see if there's a mod_jk.so module.

Configuration

1. The first is Apache related, just installed the MOD_JK module, has also been copied to the Apache module directory, the following is to let Apache to support it.
You need to create a new two configuration file in the Apache Conf directory:
Mod_jk.conf #模块本身的配置文件
Workers.properties #定义Tomcat工作的的配置文件

Vim mod_jk.conf

1. Location of Jkworkersfile/usr/local/apache2/conf/workers.properties #指定workers. Properties

2. Jklogfile/usr/local/apache2/logs/mod_jk.log #指定jk的日志输出文件

3. Jkloglevel Info #指定日志级别

4. Jklogstampformat "[%a%b%d%h:%m:%s%Y]" #指定日志输出的时间戳格式

5. Jkoptions +forwardkeysize +forwarduricompat-forwarddirectories #JkOptions指示发送给SSL密钥大小

6. Jkrequestlogformat "%w%V%T" #指定日志中时间戳后面的内容:%w: Working Tomcat instance%V: Destination IP%T: Time consuming

7. jkmount/servlet/* Worker1 #指URL指向如果有servlet, let Worker1 handle it.

8. Jkmount/*.jsp worker1 #指URL为/*.jsp page, let Worker1 to handle

Vim Workers.properties

1. Worker.list=worker1 #指定需要工作的tomcat节点, such as multiple "," split

2. Worker.worker1.type=ajp13 #指定worker1使用ajpv13协议与Tomcat进程通讯

3. Worker.worker1.host=localhost #指定worker1的位置

4. worker.worker1.port=8009 #指定worker1的工作端口

5. worker.worker1.cachesize=10 #指定worker1的缓存大小

6. worker.worker1.cache_timeout=600 #指定worker1的cache中保留一个打开的socket的时间

7. Worker.worker1.socket_keepalive=1 #此配置项为当Apache和Tomcat之间有防火墙时, how often does the OS want to send keep_alive to an inactive connection Information to prevent the firewall from disconnecting inactive network connections

8. worker.worker1.socket_timeout=300 #指定worker1上的连接在未激活的状况下持续多久, Apache will actively cut off

Here's how to modify the master configuration file for Apache httpd.conf
A. Adding index.jsp in DirectoryIndex

B. Modified to: DocumentRoot "/var/wwwroot"

C. Change to:

D. On the last side add:
LoadModule Jk_module modules/mod_jk.so
Include/usr/local/apache2/conf/mod_jk.conf

2. The following is a slight modification to the Tomcat configuration file server.xml.
To add before the tag:
#指定项目目录

Configuration to this completion. Test below:

Third, test acceptance
Mkdir/var/wwwroot
echo "Hello,the time is"

Jdk+apache+tomcat+mysql configuration Let's learn together.

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.