Nginx Server Load balancer I. nginx Installation

Source: Internet
Author: User

Many major websites in China have already adopted nginx as a Web server. After all, nginx has good performance in high concurrency, low resource consumption, and reverse proxy, learn about nginx and perform load balancing by the way.

System environment, rhel6.5 x86_64, go to the official nginx website (http://nginx.org/) to see the next, found that the main version has arrived at 1.7.3, because it is a test, so the next stable version 1.6.0 (http://nginx.org/download/nginx-1.6.0.tar.gz)

Decompress the file:

<span style="font-size:18px;">tar zxvf nginx-1.6.0</span>

Nginx rewrite depends on the PCRE Library, so you need to compile and install the PCRE Library in Linux. Download The PCRE Library first:

<span style="font-size:18px;">wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz</span>

Decompress the file:

<span style="font-size:18px;">tar zxvf pcre-8.34.tar.gz</span>

Configuration

<span style="font-size:18px;">./configure --enable-utf8</span>

I will prompt configure: Error: You need AC ++ compiler for C ++ support. It seems that PCRE is compiled by C ++ and C ++ compilation tool is installed,

<span style="font-size:18px;">yum install -y gcc gcc-c++</span>

Then configure PCRE

<span style="font-size:18px;">./configure --enable-utf8</span>
Compile and install PCRE

<span style="font-size:18px;">make && make install</span>
The installation of the PCRE Library is complete. Switch to the nginx directory and continue to install nginx.

<span style="font-size:18px;"> ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module   --with-http_gzip_static_module <span style="font-family:simsun;">--with-pcre=/usr/local/pcre-8.34/</span></span>
The premise is that the nginx user and user group need to be added. Of course, other users can be specified here.
If you are prompted to install the gzip library,

Modify./configure plus -- without-http_gzip_module in the prompt, the gzip module is temporarily unavailable in the test.

Final compilation and Installation

<span style="font-size:18px;">make && make install</span>
Now nginx installation is complete. Start nginx and test whether the installation is successful.

Switch to sbin under nginx installation directory, and then start nginx

<span style="font-size:18px;">nginx -c /home/nginx/tools/nginx/conf/nginx.conf</span>
-C is followed by the nginx configuration file path. Configure the path according to your actual path. Note that no prompt is prompted after the startup is successful. If you need to listen to the log file, open the browser, enter the IP address of the nginx installation machine. The default nginx configuration file is port 80. Therefore, enter http: // 127.0.0.1 in the browser (the IP address is configured according to your actual situation ), if the following page appears, nginx is successfully installed.

Finally, I want to add nginx command knowledge:

#/Usr/local/nginx/sbin/nginx-H
Nginx version: nginx/0.7.63
Usage: nginx [-? Hvvt] [-S Signal] [-C filename] [-P prefix] [-G directives]

Options:
-?, -H: This help
-V: Show version and exit
-V: Show version and configure options then exit
-T: Test Configuration and exit
-S signal: Send signal to a master process: Stop, quit, reopen, reload
-P Prefix: Set prefix path (default:/usr/local/nginx /)
-C filename: set configuration file (default: CONF/nginx. conf)
-G directives: set global directives out of configuration file


If you want to disable it, execute./nginx-s stop

If you need to restart, run./nginx-s reload.


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.