Install the Nginx tutorial [Windows and Linux]__linux

Source: Internet
Author: User
Tags imap install openssl openssl openssl library iptables what is nginx
Nginx:
Nginx is a lightweight Web server/reverse proxy server and e-mail (IMAP/POP3) proxy Server
Characteristics:
Reverse proxy load balancing static and dynamic separation ...
Reverse proxy:
First to understand the forward agent: We need users to manually set the proxy server IP and port number
Reverse proxy: Proxy server, the user does not need to set.

Load Balancing:
The principle is that data traffic is distributed to multiple servers to perform, reducing the pressure on each server,
Multiple servers work together to achieve the task, thereby increasing the throughput of the data.
Static and dynamic separation:
Put the static resources on the reverse server and save the user's access time.
////////////////////////////////////////////
build clusters on Linux
1. Upload the Nginx to Linux first Create a Nginx directory in/usr/local, mkdir nginx Create a folder, FTP tool uploads files to root, copying files to Cp/root/nginx-1.8.0.tar.gz/usr/local/nginx
2. Extract Nginx tar-xvf nginx-1.8.0.tar. GZ
3. Compile Nginx First
Install Dependency Pack
Yum Install gcc-c++
Yum install-y pcre pcre-devel
Yum install-y zlib zlib-devel
Yum install-y OpenSSL openssl-devel
Perform compilation
Enter the Nginx directory first
CD./nginx/
Perform
./configure

4. Install Nginx
Perform
Make
Make Install
5. Start Nginx
CD Nginx Directory
configuration file conf
start Nginx
./nginx
6. Release the port number 80
/sbin/iptables-i input-p tcp--dport 80-j ACCEPT
Add this setting to the rules in the firewall
/etc/rc.d/init.d/iptables Save
7. Modify conf file and window under the same
Configuring Clusters
///////////////////////////////////////////////////////////
Use Nginx to build a cluster on Windows
1. New two directories in G disk TOMCAT1 TOMCAT2
2. Modify TOMCAT2 port on TOMCAT1 Port +10
3. Decompression Nginx
Modify the Nginx nginx.conf file
A reverse proxy was added to the locatioin/Bottom
Proxy_pass Proxy Server
This is just a proxy for a server
4. Agent Cluster
You need to add one on the HTTP node
Upstream servlet_yujia{
Server 127.0.0.1:8080;
Server 127.0.0.1:8090;
}
Modify a location/lower reverse proxy
Proxy_pass Http://servlet_yujia
5.session sharing problem
Workaround 1: Only under Window
Web server resolution (broadcast mechanism)
Note: Low performance under Tomcat
Modify two places:
1. Modify Tomcat's Server.xml support share
Put the Engine tab under the
<cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
Note Remove
2. Modify the project's configuration file Web.xml add a node

Solution Mode 2:
The ID of the session can be placed in Redis
Solution Mode 3:
To ensure that an IP address is always accessible to a Web server, there is no session sharing problem, in Linux
In the Nginx configuration file
Add Ip_hash in upstream;





=============================================================================================================== ======================================================================== Reprint Tutorial 2
What is Nginx?

Nginx ("Engine X") is a high-performance HTTP and reverse proxy server, but also a IMAP/POP3/SMTP proxy server, in the case of high connectivity concurrency Nginx is a good alternative to Apache server. Its features are less memory, concurrency is strong, the fact The concurrency capability of the Nginx does perform well in the same type of Web server. At present, Chinese mainland use Nginx website users are: Sina, NetEase, Tencent, another well-known micro-blog Plurk also use Nginx.

Nginx as load Balancing server:

Nginx can support both Rails and PHP programs externally, as well as external services as an HTTP proxy server. Nginx use C to write, whether it is the system resource cost or CPU efficiency is much better than Perlbal. As a mail proxy server:

Nginx is also a very good mail proxy server (one of the first to develop this product is also as a mail proxy server), Last.fm describes the successful and wonderful use of experience. Nginx is a very simple installation, the configuration file is very concise (also able to support Perl syntax), Bugs very few servers: Nginx startup is particularly easy, and can almost do 7*24 non-stop operation, even if run for several months does not require a reboot. You are also able to upgrade the software version without interruption of service.

installation of Nginx

Module dependency Nginx need to rely on 3 packages below

1. Gzip Modules need zlib library (download: http://www.zlib.net/)

2. Rewrite module needs pcre library (download: http://www.pcre.org/)

3. SSL function requires OpenSSL library (download: http://www.openssl.org/)

Nginx Package Download: http://nginx.org/en/download.html

The dependent package installation sequence is: OpenSSL, zlib, Pcre, and then install the Nginx package.

Graphic Tutorials

The first step: Download the package required for installation

Openssl-fips-2.0.2.tar.gz

Zlib-1.2.7.tar.gz

Pcre-8.21.tar.gz

Nginx-1.2.6.tar.gz

Step Two: Install openssl-fips-2.0.2.tar.gz, zlib-1.2.7.tar.gz, pcre-8.21.tar.gz in sequence, nginx-1.2.6.tar.gz

1. Install openssl-fips-2.0.2.tar.gz

[Root@localhost mrms]# tar-zxvf openssl-fips-2.0.2.tar.gz 

[root@localhost mrms]# cd openssl-fips-2.0.2

[ Root@localhost openssl-fips-2.0.2]#./config 

[root@localhost openssl-fips-2.0.2]# make

[root@localhost openssl-fips-2.0.2]# make Install

2. Install zlib-1.2.7.tar.gz

[Root@localhost mrms]# tar-zxvf zlib-1.2.7.tar.gz

[root@localhost mrms]# cd zlib-1.2.7

[root@localhost zlib-1.2.7]#./configure 

[root@localhost zlib-1.2.7]# make

[root@localhost zlib-1.2.7]# make install

3. Install pcre-8.21.tar.gz

[Root@localhost mrms]# tar-zxvf pcre-8.21.tar.gz

[root@localhost mrms]# cd pcre-8.21

[root@localhost pcre-8.21]#./configure 

[root@localhost pcre-8.21]# make

[root@localhost pcre-8.21]# make install

4. Install nginx-1.2.6.tar.gz

[Root@localhost mrms]# tar-zxvf nginx-1.2.6.tar.gz 

[root@localhost mrms]# cd nginx-1.2.6

[root@localhost nginx-1.2.6]#./configure--with-pcre=. /pcre-8.21--with-zlib=. /zlib-1.2.7--with-openssl=. /openssl-fips-2.0.2

[root@localhost nginx-1.2.6]# make

[root@localhost nginx-1.2.6]# make install

This nginx installation is complete!

Step three: Detect if the installation was successful

[root@localhost nginx-1.2.6]# cd  /usr/local/nginx/sbin

[root@localhost sbin]#./nginx-t

A prompt appears as follows, indicating that the installation was successful

Start Nginx

[Root@localhost sbin]#./nginx

View ports

[Root@localhost sbin]# NETSTAT-NTLP

The results are as follows

Reprint please indicate the source [http://www.cnblogs.com/dennisit/archive/2012/12/26/2834719.html]

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.