Detailed installation configuration of MAP + TOMCAT + JDK + MYSQL connection under RHEL3U6

Source: Internet
Author: User
Detailed installation configuration of MAP + TOMCAT + JDK + MYSQL connection under RHEL3U6-Linux Enterprise Application-Linux server application information. The following is a detailed description. The main change here is that the tomcat configuration does not need to be connected to the module. What impressed me most about this tomcat is that I went to China Mobile for an interview once when I was depressed at the company. The Technical Director asked: have you used tomcat and apache integration? I said that I had never studied it. I only used resin. Then he asked me what ports I opened on tomcat and what did I do? I said I have to check the information. In fact, the three ports are 8005, 8009, and 8080. Haha, the result is conceivable-I was passed because I did not know the tomcat startup port. In fact, it is ridiculous to think about it. I am telling the truth. Is it impossible for technicians to put everything in their minds? The Chinese often say: a good brain is better than a bad pen. So I have the habit of recording and writing everything down. I just need to remember what I should remember. Well, I advise you to have a good mind for finding a good destination, it is best not to forget, or it is dangerous to find a job !! In addition, do you think you have to be familiar with English when looking for a job? I am, haha, But I have dr. eye, haha, helpless... to put it bluntly, let's start to configure the environment that used to PASS my PASS: Chapter 1: mapinstallation kernel test optimization kernel Security 1、mysqlinstall my kernel selection is mysql-4.0.25.tar.gz. This OLD version is selected because the databases of other machines are also in this version, in this way, it is convenient to export data to each other. Install it as a fool as follows. # Tar xzvf mysql-4.0.25.tar.gz # cd mysql-4.0.25 # useradd mysql-s/sbin/nologin # CFLAGS = "-O3-mpentiumpro" CXX = gcc CXXFLAGS = "-O3-mpentiumpro-felide-constructors- fno-exceptions-fno-rtti ". /configure -- prefix =/usr/local/mysql -- enable-resolver -- with-mysqld-ldflags =-all-static -- with -- charset = gbk -- with-extra-charsets = all; make; make install! About 5 minutes. -- My 1850 is similar. For more information about how to use these parameters, see. /configure -- help # cp support-files/my-huge.cnf/etc/my. cnf # cd/usr/local/mysql # bin/mysql_install_db -- user = mysql # chown-R root. # chown-R mysql var # chgrp-R mysql. # bin/mysqld_safe -- user = mysql & #/usr/local/mysql/bin/mysqladmin-u root password 'hahahaha' # mysql-pEnter password: Welcome to the MySQL monitor. commands end with or \ g. your MySQL connection id is 2 to server version: 4.0.25-logType 'help; 'or' \ H' for help. type '\ C' to clear the buffer. mysql> use mysqlDatabase changedmysql> delete from user where Password = ''; Query OK, 3 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> exitBye # cp/usr/local/mysql/share/mysql. server/etc/rc. d/init. d # chmod 500/etc/rc. d/init. d/mysql. server # cd/etc/rc. d/rc3.d # ln-s .. /init. d/my SQL. server S99mysql # ln-s .. /init. d/mysql. server K99mysqlMysql installation is complete, so we will start to install apache2.2.02 and apache-2.2.0. Here we will talk about APR, which is an Apache Portable Runtime Library, for the multi-platform nature of the server code, try to isolate the specific bytes of different operating systems from the code irrelevant to the operating system. As a result, a basic API interface is provided. For details, refer http://fanqiang.chinaunix.net/app/web/2006-02-21/4012.shtml Article. Apache-2.2.0 provides the source code of apr and apr-util. You must manually install the source code of apr/apr-util in the source code of the release: we first compile and install apr 1.2 # tar xzvf httpd -2.2.0.tar.gz # cd httpd-2.2.0 # cd srclib/apr #. /configure -- prefix =/usr/local/apr # make install now compile and install apr-util 1.2 # cd .. /apr-util #. /configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr/# make install to install and configure apache, here we need a mod_proxy_ajp module, which is used to integrate tomcat, and 2.2.0 is beautiful, haha. Cd .. /.. /#. /configure -- prefix =/usr/local/httpd220 -- enable-so -- enable-rewrite = share -- enable-proxy-ajp = share -- enable-dav = share -- with-apr =/usr/local/apr/-- with-apr-util =/usr/local/apr-util/# make install apache module: # cd/usr/local/httpd220/bin #. /httpd-l the mod_proxy_ajp.c we want is also available. Now we don't need to configure the apache conf file. We will install php directly. I use version 4.4.2 # cd/usr/local/httpd220/bin # cp apachectl/etc/init. d/httpd # cd/etc/rc3.d # ln-s .. /init. d/httpd S85httpd # ln-s .. /init. d/httpd K85httpd3, install php # tar xzvf php-4.4.2.tar.gz # cd php-4.4.2 #. /configure -- prefix =/usr/local/php442 -- with-apxs2 =/usr/local/httpd220/bin/apxs -- with-config-file-path =/usr/local/php442 -- with-mysql =/usr/local/mysql -- with-mail -- sysc Onfdir =/usr/local/php442/etc -- with-gd -- with-zlib -- with-png -- with-jpeg -- with-freetype -- enable-sockets # make; make installcp php. ini-dist/usr/local/php442/php. ini4. Install modsecurity (mod_security can enhance apache Security, especially in anti-SQL injection .) Download Site: http://www.modsecurity.org/download/# Tar zxvf modsecurity-apache-1.9.2.tar.gz # cd modsecurity-apache-1.9/apache2/#/usr/local/httpd220/bin/apxs-cia mod_security.c open httpd. check whether the following text is added to LoadModule security_module modules/mod_security.so. If not, add it to httpd. add the following mod_security configuration file in conf: SecFilterEngine OnSecFilterCheckURLEncoding OnSecFilterDefaultAction "deny, log, status: 500" # SecFilterForceByteRange 32 126 # SecFilterScanPOST OnSecAuditLog logs/audit_log ### SecFilter "\. \. /"##### SecFilter/etc/* passwdSecFilter/bin/* sh # for css attackSecFilter" <(|) * script "SecFilter" <(. |) +> "# for SQL attackSecFilter" delete [] + from "SecFilter" insert [] + into "SecFilter" select. + from "SecFilter" union [] + from "SecFilter" drop []" 5. apache2 installed mod_evasive anti-DDOS mod_evasive whose predecessor is mod_dosevasive download site: http://www.nuclearelephant.com/projects/mod_evasive# tar zxvf ready # cd mod_evasive #/usr/local/httpd220/bin/apxs-cia ready open httpd. check whether the following text is added to LoadModule evasive20_module modules/mod_evasive20.so. If not, add it to httpd. add the following mod_security configuration file in conf: DOSHashTableSize 3097 DOSPageCount 2 DOSSiteCount 50 DOSPageInterval 1 DOSSiteInterval 1 DOSBlockingPeriod 10 6. Configure httpd. conf note 2.2.0 in the default is the following users and groups, rather than the original nobodyUser daemonGroup daemonServerAdmin xu1701@hotmail.com this place configured to your own mailbox ServerName YourDomainName: 80 this place to open, you can edit documentRoot "/usr/local/httpd220/htdocs" in red. You can change it to your WEB Path Options Indexes FollowSymLinks, unless you want to display your file DirectoryIndex index.html index. jsp index. add three homepage file names in php index.htm to search for AddType application, and find AddType application/x-compre. Ss. ZAddType application/x-gzip. gz. tgz: add a line next to it. is PHP used! Haha. AddType application/x-httpd-php. php7. Start apache and check our results. First, go to your own documentRoot and create a file named test. php. The content is #/Usr/local/httpd220/bin/apachectl start access http://Your Ip/test. php if you see the php information interface, congratulations, your MAP has been initially configured. What else, optimization! 8. For php Speed Optimization, we first need to install Zend Optimizer, which can be accessed from the Zend Technologies website ( http://www.zend.com/ . Its principle is very simple. It detects intermediate code generated by the Zend engine and optimizes it to get a higher execution speed. I think code optimization is a very cumbersome task, and the optimized code may become hard to understand. Therefore, I suggest that when the PHP source code is more complex, using Zend Optimizer to do this optimization, the advantage is that it won't make your code complex and difficult to understand. Installing Zend Optimizer is very simple. Download zendoptimizer-2.6.0-linux-glibc21-i386.tar.gz # tar xzvf ZendOptimizer-2.6.0-linux-glibc21-i386.tar.gz # cd ZendOptimizer-2.6.0 #. /install. However, if you do not need remote desktop display such as vnc, it may be difficult to install it. Therefore, we recommend that you use VNC for installation. After installation, it will automatically go to your php. add the following six lines to ini: zend_optimizer.optimization_level =/usr/local/Zend/lib/Optimizer-2_6_0zend_extension_manager.optimizer_ts =/usr/local/Zend/lib/Optimizer_TS-2_6_0zend_optimizer.version = 2.6.0zend _ extension =/usr/local/Zend/lib/ZendExtensionManager. sozend_extension_ts =/usr/local/Zend/lib/ZendExtensionManager_TS.so Let's modify zend_optimizer.optimiz. The parameter of ation_level (we only modify this parameter). This parameter indicates the degree of optimization. Here we define how many optimization processes are started. The default value is 15, 1-4 of the 10 optimization processes are enabled at the same time. We can change this value to 1023, indicating that all 10 optimization processes are enabled. Zend_optimizer.optimization_level = 1023 restart apache. If Zend Technologies with Zend Optimizer v2.6.0 is displayed when test. php is executed, it indicates that it has been applied. After optimization, we also need to accelerate the code execution process. Since the author of turck-mmcache has been installed by zend, turck-mmcache has not been updated for a long time. This time we will introduce another good open-source php code optimization software, eAccelerator. The installation is simple. Follow me step by step to come first. http://eaccelerator.net/wiki/ Download the latest version, which is currently eaccelerator-0.9.4 # unzip eaccelerator-0.9.4.zip # export PHP_PREFIX = "/usr/local/php442" # cd eaccelerator-0.9.4 # $ PHP_PREFIX/bin/phpize #. /configure -- enable-eaccelerator = shared -- with-php-config = $ PHP_PREFIX/bin/php-config # make install after the installation is complete, you will see the following sentence, note that your path may be different from mine. /Usr/local/php442/lib/php/extensions/no-debug-non-zts-20020429/then we will configure php. ini. According to your system, there are two installation methods: Zend extension and PHP extension. If it is the former, please go to your php. add the following code to ini: zend_extension = "/usr/local/php442/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator. so "eaccelerator. shm_size = "16" eaccelerator. cache_dir = "/tmp/eaccelerator" eaccelerator. enable = "1" eaccelerator. optimizer = "1" eaccelerator. check_mtime = "1" eaccelerator. debug = "0" eaccelerator. filter = "" eaccelerator. shm_max = "0" eaccelerator. shm_ttl = "0" eaccelerator. shm_prune_period = "0" eaccelera Tor. shm_only = "0" eaccelerator. compress = "1" eaccelerator. compress_level = "9" if your system has enabled the security mode, you must use "zend_extension_ts" to replace "zend_extension ". PHP extension installation mode, please go to your php. add extension = "/usr/local/php442/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator to ini. so "eaccelerator. shm_size = "16" eaccelerator. cache_dir = "/tmp/eaccelerator" eaccelerator. enable = "1" eaccelerator. optimizer = "1" eaccelerator. check_mtime = "1" eaccele Rator. debug = "0" eaccelerator. filter = "" eaccelerator. shm_max = "0" eaccelerator. shm_ttl = "0" eaccelerator. shm_prune_period = "0" eaccelerator. shm_only = "0" eaccelerator. compress = "1" eaccelerator. compress_level = "9" is modified and saved. Create the cache folder # mkdir/tmp/eaccelerator # chmod 0777/tmp/eaccelerator and restart apache. php: You can see eAccelerator v0.9.4, Copyright (c) 2004-2004 eAccelerator, by eAccelerator with Zend Extension. Chapter 2: Jdk + Tomcat installation and configuration 1. Jdk installation is the abbreviation of Java Development Kit. It is a development environment used to build applications, applets, and components released on the Java platform. Jdk is the basis of all java applications, and all java applications are built on it. It is a set of APIS, or java Class. Download Site: http://java.sun.com/j2se/1.5.0/download.jsp Latest Version: JDK 5.0 Update 6 below start installation # rpm-qa | grep libgcjlibgcj-3.2.3-53libgcj-ssa-devel-3.5ssa-0.20030801.48libgcj-ssa-3.5ssa-0.20030801.48libgcj-devel-3.2.3-53 # rpm-e gcc-java-3.2.3-53 # rpm-e libgcj-devel # rpm-e redhat-lsb # rpm-e gettext-0.11.4-7 # rpm -e libgcj # chmod + x jdk-1_5_0_06-linux-i586-rpm.bin #. jdk-1_5_0_06-linux-i586-rpm.bin # vi ~ /. Bash_profile: JAVA_HOME =/usr/java/jdk1.5.0 _ 06 CLASSPATH = $ JAVA_HOME/lib/tools. jar: $ JAVA_HOME/lib/dt. jarPATH = $ PATH: $ HOME/bin: $ JAVA_HOME/jre/binBASH_ENV = $ HOME /. bashrcTOMCAT_HOME =/usr/local/tomcatUSERNAME = "root" export USERNAME BASH_ENV PATH JAVA_HOME CLASSPATH TOMCAT_HOME make the environment variable take effect # source ~ /. Bash_profile # java # If java and javac run, the java environment variable is configured successfully. 2. Tomcat installation and download site: http://apache.linuxforum.net/dist/jakarta/tomcat-5/ Latest Version 5.5.16 # tar zxvf apache-tomcat-5.5.16.tar.gz # mv apache-tomcat-5.5.16/usr/local/tomcattomcat this thing is almost unzipped after it can run 3, configure tomcat and apache integration # vi/usr /local/tomcat/conf/web. xml JavaEncoding GB18030 Add the above text 3 To make the configuration file readable, modify the apache configuration file again and turn on vi/usr/local/httpd220/conf/httpd. conf # Virtual hostsInclude conf/extra/httpd-vhosts.conf # vi/usr/local/httpd220/conf/extra/httpd-vhosts.confNameVirtualHost YourIp: 80 DirectoryIndex index. jsp ProxyPass/ajp: // localhost: 8009/ProxyPassReverse/ajp: // localhost: 8009/ServerAdmin Yourname @ DOMAIN ServerName YourIp ServerAlias www ErrorLog logs/YourIp-error_log CustomLog logs/YourIp-access_log common 4. start tomcat and apache #/usr/local/tomcat/bin/startup. shUsing CATALINA_BASE:/usr/local/tomcatUsing CATALINA_HOME:/usr/local/tomcatUsing CATALINA_TMPDIR:/usr/local/tomcat/tempUsing JRE_HOME: /usr/java/jdk1.5.0 _ 06 #/usr/local/httpd220/bin/apachectl restart5. Access test http: // YourIp/. What do you see? If you can see the default tomcat page, congratulations, tomcat and apache have been integrated successfully. Chapter 3: mysqlconnection pool addition and test download the latest mysql-connector-java-3.1.12.tar.gz # tar xzvf mysql-connector-java-3.1.12.tar.gz # cd mysql-connector-java-3.1.12 # cp mysql-connector-java-3.1.12-bin.jar/usr/local/tomcat/common/lib # vi ~ /. Bash_profile modify CLASSPATH = $ JAVA_HOME/lib/tools. jar: $ JAVA_HOME/lib/dt. jar is CLASSPATH = $ JAVA_HOME/lib/tools. jar: $ JAVA_HOME/lib/dt. jar:/usr/local/tomcat/common/lib/mysql-connector-java-3.1.12-bin.jar update bash #. ~ /. Bash_profile we will use the VM to test # mkdir/usr/local/httpd220/htdocs/test # cd/usr/local/httpd220/htdocs/test # vi index later. the jsp content is as follows: <% @ page contentType = "text/html; charset = gb2312" %> <% @ page import = "java. SQL. * "%> Test JSP page (Tomcat + MySQL)<% Class. forName ("org. gjt. mm. mysql. Driver"). newInstance (); String url = "jdbc: mysql: // localhost: 3306/mysql? User = root & password = YorPass & useUnicode = true & characterEncoding = GB2312 "; Connection conn = DriverManager. getConnection (url); Statement stmt = conn. createStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE); String SQL = "select * from user"; ResultSet rs1_stmt.exe cuteQuery (SQL); %>
The content of your first field is:

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.