1: modify centos command line to start (reduce memory usage ):
Vim/etc/inittab id: 5: initdefault: --> Change 5 to 3.
To start startx
2: install jdk
1) Unzip: jdk-7u55-linux-i586.tar.gz
[Root @ localhost jdk] # tar-zxvf jdk-7u55-linux-i586.tar.gz
2) copy: [root @ localhost jdk] # cp-rf jdk1.7.0 _ 55 // usr/local/jdk
3) configure the environment. [root @ localhost bin] # vim/etc/profile
Insert at the end: export JAVA_HOME =/usr/local/jdk/jdk1.7.0 _ 79
Export PATH = $ JAVA_HOME/bin: $ PATH
4) refresh the configuration file: source/etc/profile
Verification: java javac
3: install tomcat
1) decompress: tar-zxvf
2) authorization: chmod u + x/usr/local/tomcats/tomcat1/apache-tomcat-7.0.47/bin
3) start: Enter the bin directory of tomcat:./startup. sh
4) open port: vim/etc/sysconfig/iptables
5) disable the firewall: chkconfig iptables off
6) restart the firewall: service iptables restart
7) modify the port number: vim conf/server. xml
8) view the process: ps aux | grep tomcat
4: install nginx
1) installation environment:
Yum-y install gcc-c ++
Yum-y install pcre-devel
Yum-y install zlib-devel
Yum-y install openssl-devel
2) Unzip: tar-zxvf nginx-1.8.0.tar.gz
3) Mobile: music nginx-1.8.0/usr/local/nginx/
4) create a temporary directory: var] # mkdir-p temp/nginx
5) enter the directory: cd nginx-1.8.0/
6) modify parameters:
./Configure \
-- Prefix =/usr/local/nginx \
-- Pid-path =/var/run/nginx. pid \
-- Lock-path =/var/lock/nginx. lock \
-- Error-log-path =/var/log/nginx/error. log \
-- Http-log-path =/var/log/nginx/access. log \
With-http_gzip_static_module \
-- Http-client-body-temp-path =/var/temp/nginx/client \
-- Http-proxy-temp-path =/var/temp/nginx/proxy \
-- Http-fastcgi-temp-path =/var/temp/nginx/fastcgi \
-- Http-uwsgi-temp-path =/var/temp/nginx/uwsgi \
-- Http-scgi-temp-path =/var/temp/nginx/scgi
7) compile and install:
Make
Make install
8) start: cd/usr/local/nginx/sbin/
./Nginx
9) view the process: ps aux | grep nginx
10) stop:./nginx-s stop
11) complete stop:./nginx-s quit. Stop this method until the nginx process finishes processing the task. Recommended
12) restart:./nginx-s quit
./Nginx
13) reload the configuration file:./nginx-s reload
5. Configure the VM:
1. Configuration of three virtual hosts supported by nginx:
Ip-based VM
Domain name-based VM
Port-based VM
2. nginx configuration file structure: each service is a virtual host
......
Events {
......
}
Http {
.......
Server {
......
}
Server {
......
}
}
3. ip-based VM configuration:
Modify the configuration file: vim/usr/local/nginx/nginx-1.8.0/conf/nginx. conf
Server {
Listen 80;
Server_name 192.168.31.88;
Location /{
Root html;
Index index.html index.htm;
}
}
4. Domain name-based VM configuration:
Modify the configuration file: vim/usr/local/nginx/nginx-1.8.0/conf/nginx. conf
Server {
Listen 80;
Server_name www.nginxdns1.com;
Location /{
Root html_dns1;
Index index.html index.htm;
}
}
Server {
Listen 80;
Server_name www.nginxdns2.com;
Location /{
Root html_dns2;
Index index.html index.htm;
}
}
5. Port-based VM configuration:
Modify the configuration file: vim/usr/local/nginx/nginx-1.8.0/conf/nginx. conf
Listening port: netstat-an | grep 80
Server {
Listen 88;
Server_name 192.168.31.88;
Location /{
Root html_port1;
Index index.html index.htm;
}
}
Server {
Listen 89;
Server_name 192.168.31.88;
Location /{
Root html_port2;
Index index.html index.htm;
}
}
6. nginx Reverse proxy:
Modify hosts: # nginx Reverse proxy Environment Test
192.168.31.88 www.nginxproxy1.com
192.168.31.88 www.nginxproxy2.com
Enable two tomcat servers in different virtual machines: 192.168.31.88: 8080 and 192.168.31.89: 8081.
Modify the configuration file:
# Proxy worker AT1 server
Upstream tomcat_server1 {
Server 192.168.31.89: 8081;
}
# Proxy Tomcat 2 server
Upstream tomcat_server2 {
Server 192.168.31.88: 8080;
}
# Configure a VM:
Server {
Listen 80;
Server_name www.nginxproxy1.com;
Location /{
# Root html_port1;
Proxy_pass http: // tomcat_server1;
Index index.html index.htm;
}
}
Server {
Listen 80;
Server_name www.nginxproxy2.com;
Location /{
# Root html_port2;
Proxy_pass http: // tomcat_server2;
Index index.html index.htm;
}
}
7. nginx load balancing:
Modify hosts: # Test the nginx server load balancer environment
192.168.31.88 www.nginxbalance.com
Enable two tomcat servers in different virtual machines: 192.168.31.88: 8080 and 192.168.31.89: 8081.
Modify the configuration file:
# Proxy Tomcat 2 server
Upstream tomcat_server_pool {
Server 192.168.31.88: 8080 weight = 1;
Server 192.168.31.89: 8081 weight = 1;
}
# Configure a VM:
Server {
Listen 80;
Server_name www.nginxbalance.com;
Location /{
# Root html_port1;
Proxy_pass http: // tomcat_server_pool;
Index index.html index.htm;
}
}
Hosts file configuration:
1: testing nginx based on the domain name environment
192.168.31.88 www.nginxdns1.com
192.168.31.88 www.nginxdns2.com
2: nginx Reverse proxy Environment Test
192.168.31.88 www.nginxproxy1.com
192.168.31.88 www.nginxproxy2.com
3: nginx server load balancer Environment Test
192.168.31.88 www.nginxbalance.com