Successful installation of CentOS 5.5 Nginx + JDK + MySQL + Tomcat (jsp)

Source: Internet
Author: User
Tags openldap apache tomcat

It is very easy to install Nginx + jdk + mysql + tomcat in Centos 5.5. You only need to install the environment package and nginx in yum, decompress and install jdk and tomcat, configure the profile file, server. xml, and nginx. conf files. The procedure is as follows:

1. Install the environment package
1. First, use the yum command to install and upgrade the required library.
Yum-y install gcc-c ++ autoconf libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel glibc-devel
Glib2 glib2-devel bzip2 bzip2-devel ncurses-devel curl-devel e2fsprogs e2fsprogs-devel krb5-server krb5-devel libidn-devel openldap

Openldap-devel nss_ldap openldap-clients openldap-servers
2. Install mysql in yum
First check whether mysql is installed:
Rpm-qa | grep mysql
If the installation is not complete, execute the following yum
Yum install mysql-test mysql-devel mysql-server mysql
3. Install prce in yum
First check whether prce is installed:
Rpm-qa | grep prce
If the following yum
Yum install prce

Ii. Install nginx in yum
1. Install the latest stable version of nginx yum Source
The latest version of Nginx yum source is in the epel rpm package. You can download and install wget.
Cd/root
Wget http://download.Fedora.RedHat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Rpm-ivh epel-release-5-4.noarch.rpm
2. Install nginx
Yum install nginx
3. Start testing nginx
Service nginx restart
There are two processes after Nginx is started. The master is the master process and the worker is the worker process.
After NGINX is started, you can enter http: // localhost in the browser to view welcome to nginx.
3. Install jdk
1. First download jdk and install jdk.
# Cd/root
# Wget http://cds-esd.sun.com/ESD6/JSCDL/jdk/6u23-b05/jdk-6u23-linux-i586.bin? AuthParam = 12925481__5c40501ebcb0ead52c24198a34e7e6ee & TicketId = B %

2Fw3nB2ESl1MSxRGMlFYlQHl & GroupName = CDS & FilePath =/ESD6/JSCDL/jdk/6u23-b05/jdk-6u23-linux-i586.bin & File = jdk-6u23-linux-i586.bin
After the download, modify the jdk-6u23-linux-i586.bin file properties to executable, www.linuxidc.com then execute the program installation
# Chmod + x jdk-6u23-linux-i586.bin
# Cd./jdk-6u23-linux-i586.bin
# Mv jdk1.6.0 _ 23/usr/local/jdk
2. Edit the profile file to set the Startup File. java boot Execution Environment File
# Vi/etc/profile
Add the following content at the end of the file:
JAVA_HOME = "/usr/local/jdk"
CLASS_PATH = "$ JAVA_HOME/lib: $ JAVA_HOME/jre/lib"
PATH = ".: $ PATH: % JAVA_HOME/bin"
CATALINA_HOME = "/usr/local/tomcat"
Export JAVA_HOME CATALINA_HOME
Save and exit vi, execute the following command to make the configuration take effect, and restart the computer
# Source/etc/profile
# Reboot

4. install apache tomcat
1. Download apache tomcat and install tomcat
# Cd/root
# Mkdir/www // create the webpage root directory
# Cp/usr/share/nginx/html/*/www/
# Wget http://apache.etoak.com/tomcat/tomcat-7/v7.0.5-beta/bin/apache-tomcat-7.0.5.tar.gz

# Tar zxvf apache-tomcat-7.0.5.tar.gz
# Mv apache-tomcat-7.0.5/usr/local/tomcat
# Cp-rf/usr/local/tomcat/webapps/*/www/
2. Configure the tomcat server. xml file and start or stop tomcat
# Vim/usr/local/tomcat/conf/server. xml
Search for appBase = "webapps" and change it to appBase = "/www"./www is the root directory of the webpage.
Start tomcat after installation. The default listening port is 8080.
#/Usr/local/tomcat/bin/startup. sh
To stop tomcat, run the following command:
#/Usr/local/tomcat/bin/shutdown. sh
V. Integration of nginx and tomcat
To integrate Nginx with tomcat, you only need to configure the nginx. conf file.
# Vim/etc/nginx. conf // The configured nginx. conf file is as follows (pay attention to the red part)
User nginx;
Worker_processes 1;
Error_log/var/log/nginx/error. log;
Pid/var/run/nginx. pid;
Events {
Use epoll;
Worker_connections 65535;
}
Http {
Include/etc/nginx/mime. types;
Default_type application/octet-stream;
Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" "$ http_x_forwarded_for "';
Access_log/var/log/nginx/access. log main;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 32 k;
Large_client_header_buffers 4 32 K;
Client_max_body_size 8 m;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 65;
# Tomcat add start <
Tcp_nodelay on;
Client_body_buffer_size 512 k;
Proxy_connect_timeout 5;
Proxy_read_timeout 60;
Proxy_send_timeout 5;
Proxy_buffer_size 16 k;
Proxy_buffers 4 64 k;
Proxy_busy_buffers_size 128 k;
Proxy_temp_file_write_size 128 k;
# Tomcat add end>
Gzip on;
Gzip_min_length 1 k;
Gzip_buffers 4 16 k;
Gzip_http_version 1.1;
Gzip_comp_level 2;
Gzip_types text/plain application/x-javascript text/css application/xml;
Gzip_vary on;
# Tomcat add start <
Upstream tomcat_server {
Server 127.0.0.1: 8080;
}
# Tomcat add end>
Server {
Listen 80;
Server_name _;
# Charset koi8-r;
# Access_log logs/host. access. log main;
Location /{
Root/www;
Index index.html index.htm index. jsp default. jsp index. do default. do;
}
# Tomcat add start <
If (-d $ request_filename)
{
Rewrite ^/(. *) ([^/]) $ http: // $ host/$1 $2/permanent;
}
Location ~ \. (Jsp | jspx | do )? $ {
Proxy_set_header Host $ host;
Proxy_set_header X-Forwarded-For $ remote_addr;
Proxy_passhttp: // tomcat_server;
}
# Tomcat add end>
Error_page 404/404 .html;
Location =/404.html {
Root/www;
}
# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root/www;
}
# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
#
# Location ~ \. Php $ {
# Proxy_pass http://www.bkjia.com;
#}
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
# Ocation ~ \. Php $ {
# Root html;
# Fastcgi_pass 127.0.0.1: 9000;
# Fastcgi_index index. php;
# Fastcgi_param SCRIPT_FILENAME/www $ fastcgi_script_name;
# Include fastcgi_params;
#}
# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
# Location ~ /\. Ht {
# Deny all;
#}
}
# Load config files from the/etc/nginx/conf. d directory
Include/etc/nginx/conf. d/*. conf;
}
Vi. Test
Start nginx
# Service nginx restart
After Nginx is started, you can access the jsp instance program in the following URL to check whether the jsp program can run.
Http: // localhost/examples/jsp/
Note: the working principle of nginx and tomcat is that the nginx proxy tomcat outputs the webpage. Therefore, if the firewall is enabled, the firewall does not need to open port 8080. You can also access the jsp page.

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.