Install nginx on centos

Source: Internet
Author: User

Download the latest nginxfile and install it at http://nginx.org/en/download.html.

1. download and install the PCRE LibraryFtp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

Tar zxvf pcre-8.30.tar.gz./configure make install 2 install OpenSSL Yum-y install OpenSSL-devel 3 download tcp_proxy_module to https://github.com/yaoweibin/nginx_tcp_proxy_module download 4 install nginxexport nginx_version = 1.2.1curl-O uninstall-xvzf uninstall
CD nginx-$ nginx_version
Patch-P1 <../nginx_tcp_proxy_module/tcp. Patch
./Configure -- add-module = ../nginx_tcp_proxy_module/
Sudo make & make install

When nginx is started, the service cannot be started and the error libpcre. so.1 not found occurs. The solution is as follows:

Run the following command to view

--- # LDD $ (which/usr/sbin/nginx)

Shown as follows:

Linux-vdso.so.1 => (0x00007fff7e9db000)
Libpthread. so.0 =>/lib64/libpthread. so.0 (0x00007fe4629d0000)
Libcrypt. so.1 =>/lib64/libcrypt. so.1 (0x00007fe462799000)
Libpcre. so.1 => not found//Not Found
Libz. so.1 =>/lib64/libz. so.1 (0x00007fe462582000)
Libc. so.6 =>/lib64/libc. so.6 (0x00007fe4621e1000)
/Lib64/ld-linux-x86-64.so.2 (0x00007fe462bfa000)
Libfreebl3.so =>/lib64/libfreebl3.so (0x00007fe461f7e000)
Libdl. so.2 =>/lib64/libdl. so.2 (0x00007fe461d7a000)

Run the following command:

---- # Cd/lib64

---- # Ln-s libpcre. so.0.0.1 libpcre. so.1

Check again:

---- # LDD $ (which/usr/sbin/nginx)

It is OK:

Linux-vdso.so.1 => (0x00007fff4d7ff000)
Libpthread. so.0 =>/lib64/libpthread. so.0 (0x00007fb06f13e000)
Libcrypt. so.1 =>/lib64/libcrypt. so.1 (0x00007fb06ef07000)
Libpcre. so.1 =>/lib64/libpcre. so.1 (0x00007fb06ecda000)
Libz. so.1 =>/lib64/libz. so.1 (0x00007fb06eac4000)
Libc. so.6 =>/lib64/libc. so.6 (0x00007fb06e723000)
/Lib64/ld-linux-x86-64.so.2 (0x00007fb06f0000000)
Libfreebl3.so =>/lib64/libfreebl3.so (0x00007fb06e4c0000)
Libdl. so.2 =>/lib64/libdl. so.2 (0x00007fb06e2bc000)

 

Load Balancing http://cnodejs.org/topic/4f16442ccae1f4aa270010b3 for websocket applications

Reverse Proxy web sockets with nginx and socket. iohttp: // www.letseehere.com/reverse-proxy-web-sockets


Possible Installation Problems

1. If you configure the parameters after./configure, the following error is prompted:

Objs/src/HTTP/modules/ngx_http_browser_module.o \

Objs/src/HTTP/modules/ngx_http_upstream_ip_hash_module.o \

Objs/src/HTTP/modules/ngx_http_upstream_least_conn_module.o \

Objs/src/HTTP/modules/ngx_http_upstream_keepalive_module.o \

Objs/ngx_modules.o \

-Lpthread-lcrypt-lpcre-lcrypto-LZ

Objs/src/CORE/ngx_regex.o: In function 'ngx _ pcre_free_studies ':

/Share/nginx-1.2.4/src/CORE/ngx_regex.c: 307: Undefined reference to 'pcre _ free_study'

Collect2: LD returned 1 exit status

Make [1]: *** [objs/nginx] Error 1

Make [1]: Leaving directory '/share/nginx-1.2.4'

Make: *** [Build] Error 2

Solution:

./Configure -- prefix =/usr/local/nginx -- without-http_autoindex_module -- without-http_geo_module -- without-http_map_module -- without-http_browser_module -- with-http_stub_status_module -- With-PCRE = ../with-http_realip_module

PS:./configure -- prefix =/usr/localnx -- without-http_autoindex_module -- without-http_geo_module -- With-PCRE = ../pcre-8.31

Note: Replace -- With-PCRE = ../pcre-8.31 with the path of your PCRE decompression package

2. If "-- with-http_gzip_static_module" (add gzip compression module) is added after "./configure", the following error is reported:

./Configure: error: the HTTP gzip module requires the zlib library.

You can either disable the module by using -- without-http_gzip_module

Option, or install the zlib library into the system, or build the zlib library

Statically from the source with nginx by using -- With-zlib = <path> option.

Solution: Install the zlib-devel package

# Yum-y install zlib-devel

Problems with starting nginx:

#/Usr/local/nginx/sbin/nginx

1./usr/local/nginx/sbin/nginx: Error while loading shared libraries: libpcre. so.1: cannot open shared object file: no such file or directory

The error indicates that the Lib file is missing. For more information, see

# LDD $ (which/usr/local/nginx/sbin/nginx)

Linux-gate.so.1 => (0x0071b000)

Libpthread. so.0 =>/lib/libpthread. so.0 (0 × 00498000)

Libcrypt. so.1 =>/lib/libcrypt. so.1 (0 × 00986000)

Libpcre. so.1 => not found

Libcrypto. so.6 =>/lib/libcrypto. so.6 (0 × 00196000)

Libz. so.1 =>/lib/libz. so.1 (0 × 00610000)

Libc. so.6 =>/lib/libc. so.6 (0x002d7000)

/Lib/ld-linux.so.2 (0x006a8000)

Libdl. so.2 =>/lib/libdl. so.2 (0x008c3000)

It can be seen that libpcre. so.1 => not found is not found. Go to the/lib directory and manually click

# Ln-s libpcre. so.0.0.1 libpcre. so.1

Then it is OK to start nginx.

#/Usr/local/nginx/sbin/nginx

# Ps-Aux | grep nginx

Warning: bad syntax, perhaps a bogu '-'? See/usr/share/doc/procps-3.2.7/faq

Root 28254 0.0 0.0 2688 460? SS nginx: Master process/usr/local/nginx/sbin/nginx

Nobody 28255 0.0 0.0 2860? S nginx: Worker Process

Root 28265 0.0 0.0 4160 688 pts/1 R + grep nginx


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.