linux centos install nginx

 

If this error is reported./configure: error: SSL modules require the OpenSSL library.

install yum -y install openssl openssl-devel

 

1. Introduction to Nginx

Nginx is a high-performance HTTP and reverse proxy server developed by Russian Igor Sysoev. Nginx can choose efficient epoll, kqueue, eventport as the network I/O model. In the case of high concurrency, Nginx is a good substitute for Apache. It can support up to 50,000 concurrent connections, but the memory and CPU usage is very high. low, the operation is very stable.

Nginx has been running on Rambler Media, the largest portal site in Russia, for 3 years. At the same time, 20% of virtual hosts in Russia use Nginx as a response proxy server.

In China, there are already Sina Blog, NetEase News, Six Room, etc. that use Nginx as a Web server or reverse proxy server.

2. Nginx development

In January 2009, a sample survey was conducted on 185,497,213 websites, and it was found that the GWS and GFE servers developed by google for their own use only were used. The top two were Apache and Microsoft IIS, and Nginx had surpassed Lighttpd. , ranked third.

Second, the advantages of Nginx

(1) Nginx can be compiled and run on most Unix like OS, and there is a Windows ported version. The 1.2.6 stable version of Nginx has been released on December 11, 2012, and [1] the 1.3.10 development version has been released on December 25, 2012. If you create a new site, it is recommended to use the latest stable version as the production version. The urgency of site upgrade is not high. The source code of Nginx uses a 2-clause BSD-like license.

(2) Nginx is a very powerful high-performance web and reverse proxy server. It has many very superior features: in the case of high connection concurrency, Nginx is a good substitute for Apache servers: Nginx is a virtual host in the United States One of the software platforms often chosen by business owners. Able to support responses up to 50,000 concurrent connections, thanks to Nginx for choosing epoll and kqueue as our development model.

(3) Nginx as a load balancing server: Nginx can directly support Rails and PHP programs to serve externally, and can also support external services as an HTTP proxy server. Nginx is written in C, which is much better than Perlbal in terms of system resource overhead and CPU usage efficiency. As a mail proxy server: Nginx is also a very good mail proxy server (one of the first purposes of developing this product was also as a mail proxy server), Last.fm describes a successful and wonderful experience using it.

(4) Nginx is a server with very simple installation, very concise configuration file (it can also support perl syntax), and very few Bugs: Nginx is very easy to start, and can run almost 7*24 uninterrupted, even if running several Month also does not require a reboot. You can also upgrade software versions without interruption of service.

CentOS  6.2 actual deployment of Nginx+MySQL+PHP http://www.linuxidc.com/Linux/2013-09/90020.htm 

Use Nginx to build a WEB serverhttp ://www.linuxidc.com/Linux/2013-09/89768.htm 

The whole process of building a web server based on Linux6.3+Nginx1.2+PHP5+MySQL5.5http: //www.linuxidc.com/Linux/2013-09/89692.htm 

Nginx performance tuning under CentOS 6.3http : //www.linuxidc.com/Linux/2013-09/89656.htm 

Configure Nginx to load ngx_pagespeed module under CentOS 6.3http : //www.linuxidc.com/Linux/2013-09/89657.htm 

CentOS 6.4 installation and configuration Nginx+Pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm 

Nginx builds video-on-demand server (simulation of professional streaming media software) http://www.linuxidc.com/Linux/2012-08/69151.htm 

3. Nginx installation

The official website of Nginx is http://nginx.org/cn/, from which you can get the latest version information of Nginx. Nginx has three versions: stable, development and historical stable. The stable version is generally recommended. Specific steps are as follows:

(1) Install dependent software pcre-devel and libevent

[root@bogon nginx]# yum install pcre-devel  libevent  openssl

(2 ) Install and configure nginx #wget http://nginx.org/download/nginx-1.5.9.tar.gz

[root@bogon nginx]# tar -zxvf nginx-1.6.0.tar.gz -C /usr/local/src/

[root@bogon nginx]# cd /usr/local/src/nginx-1.6.0/

[root@bogon nginx-1.6.0]# ./configure  --conf-path=/etc/nginx/nginx.conf  --error-log-path=/var/log/nginx/error.log  --http-log-path=/var/log/nginx/access.log  --pid-path=/var/run/nginx/nginx.pid  --lock-path=/var/lock/nginx.lock  --user=nginx  --group=nginx  --with-http_ssl_module  --with-http_flv_module  --with-http_stub_status_module  --with-http_gzip_static_module  --http-client-body-temp-path=/var/tmp/nginx/client/  --http-proxy-temp-path=/var/tmp/nginx/proxy/  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/  --with-pcre

[root@bogon nginx-1.6.0]# make && make install

(3) In order to be able to start the service, the control script should be placed in the search path, so the /etc/profile file should be edited

[root@bogon nginx]# vim /etc/profile

加上PATH=$PATH:/usr/local/nginx/sbin

[root@bogon nginx]# . /etc/profile

//Test for syntax errors

[root@bogon ~]# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: [emerg] getpwnam("nginx") failed

nginx: configuration file /etc/nginx/nginx.conf test failed

From the above, there is an error, the reason is that the user and group are not created

//create user and group

[root@bogon ~]# groupadd -r nginx

[root@bogon ~]# useradd -r -g nginx nginx

//Since the /var/tmp/nginx/client/ directory and the /var/tmp/nginx/proxy/ directory are specified during the compilation process, these two directories should be created.

[root@bogon ~]# mkdir -pv /var/tmp/nginx/client

[root@bogon ~]# mkdir -pv /var/tmp/nginx/proxy

//Start the nginx service and view the port

[root@bogon ~]# nginx

[root@bogon ~]# netstat -tupln |grep nginx

tcp    0  0 0.0.0.0:80  0.0.0.0:*  LISTEN  10868/nginx

The above information appears to indicate that nginx has been started

Enter 192.168.186.132 in the browser. If the nginx welcome interface (as follows) appears, the installation is successful:

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326992414&siteId=291194637