Install Nginx service and nginx Service

Source: Internet
Author: User
Tags openssl library

Install Nginx service and nginx Service

Nginx features:

Static small files (1 MB), supporting high concurrency, and consuming little system resources. 3 W concurrency, 10 processes, memory 150 M.

Nginx features:

1. simple configuration, flexible and lightweight.

2. High concurrency (static small files) and tens of thousands of static concurrency.

3. Few resources are occupied. Concurrent activation of 10 thread services, with memory consumption of several hundred MB.

4. There are many functional categories (Web, cache, proxy), and each function is not particularly powerful.

5. Supports the epoll model so that Nginx can support high concurrency! Apache (select model ).

6. Nginx can be used with dynamic services (FASTCGI Interface)

7. Using nginx, you can speed up IP addresses and limit the number of connections.

1.1 Nginx Installation

1.1.1 create an Nginx virtual user

 

-1 [root @ Web-lnmp02 ~] # Useradd nginx-s/sbin/nologin-M # prohibit users from logging on to ssh without creating a home directory 2 [root @ Web-lnmp02 ~] # Id nginx3 uid = 501 (nginx) gid = 501 (nginx) groups = 501 (nginx) 4 [root @ Web-lnmp02 ~] #

 

1.1.2 install the pcre

 1 [root@Web-lnmp02 tools]# rpm -qa pcre pcre-devel                   2 pcre-7.8-7.el6.x86_64 3 [root@Web-lnmp02 tools]# yum install -y pcre pcre-devel 4 Loaded plugins: fastestmirror, security 5 Setting up Install Process 6 Loading mirror speeds from cached hostfile 7  * base: mirrors.sina.cn 8  * extras: mirrors.opencas.cn 9  * updates: centos.ustc.edu.cn10 Package pcre-7.8-7.el6.x86_64 already installed and latest version11 Resolving Dependencies12 --> Running transaction check13 ---> Package pcre-devel.x86_64 0:7.8-7.el6 will be installed14 --> Finished Dependency Resolution15 16 Dependencies Resolved17 18 ================================================================================19  Package              Arch             Version             Repository      Size20 ================================================================================21 Installing:22  pcre-devel           x86_64           7.8-7.el6           base           320 k23 24 Transaction Summary25 ================================================================================26 Install       1 Package(s)27 28 Total download size: 320 k29 Installed size: 957 k30 Downloading Packages:31 pcre-devel-7.8-7.el6.x86_64.rpm                          | 320 kB     00:00     32 Running rpm_check_debug33 Running Transaction Test34 Transaction Test Succeeded35 Running Transaction36   Installing : pcre-devel-7.8-7.el6.x86_64                                  1/1 37   Verifying  : pcre-devel-7.8-7.el6.x86_64                                  1/1 38 39 Installed:40   pcre-devel.x86_64 0:7.8-7.el6                                             41 [root@Web-lnmp02 tools]# rpm -qa pcre pcre-devel      42 pcre-7.8-7.el6.x86_6443 pcre-devel-7.8-7.el6.x86_64

1.1.3 install SSL Modules and OpenSSL library

 

1 [root@Web-lnmp02 ~]# yum install -y openssl-devel2 [root@Web-lnmp02 ~]# rpm -qa|grep openssl        3 openssl-1.0.1e-42.el6_7.2.x86_644 openssl-devel-1.0.1e-42.el6_7.2.x86_645 openssl098e-0.9.8e-18.el6_5.2.x86_64

 

1.1.4 download Nginx and compile and install Nginx

 

1 [root @ Web-lnmp02 tools] # wget http://nginx.org/download/nginx-1.6.3.tar.gz 2 -- 20:50:36 -- http://nginx.org/download/nginx-1.6.3.tar.gz 3 4 [root @ Web-lnmp02 tools] # ll 5 total 788 6-rw-r --. 1 root 805253 Apr 8 2015 nginx-1.6.3.tar.gz 7 [root @ Web-lnmp02 tools] # tar xf nginx-1.6.3.tar.gz # unzip 8 [root @ Web-lnmp02 tools] # ll 9 total 79210 drwxr-xr-x. 8 1001 1001 4096 Apr 7 2015 nginx-1.6.311-rw-r --. 1 root 805253 Apr 8 2015 nginx-1.6.3.tar.gz12 [root @ Web-lnmp02 tools] #

 

Compile and install Nginx

 

1 [root @ Web-lnmp02 tools] # cd nginx-1.6.3 2 [root @ Web-lnmp02 nginx-1.6.3] # ls-lk 3 total 624 4 drwxr-xr-x. 6 1001 1001 4 Nov 28 auto 5-rw-r --. 1 1001 1001 232 Apr 7 2015 CHANGES 6-rw-r --. 1 1001 1001 353 Apr 7 2015 CHANGES.ru 7 drwxr-xr-x. 2 1001 1001 4 Nov 28 conf 8-rwxr-xr-x. 1 1001 1001 3 Apr 7 2015 configure 9 drwxr-xr-x. 4 1001 1001 4 Nov 28 contrib10 drwxr-xr-x. 2 1001 1001 4 Nov 28 html11-rw-r --. 1 1001 1001 2 Apr 7 2015 LICENSE12 drwxr-xr-x. 2 1001 1001 4 Nov 28 man13-rw-r --. 1 1001 1001 1 Apr 7 2015 README14 drwxr-xr-x. 8 1001 1001 4 Nov 28 src15 [root @ Web-lnmp02 nginx-1.6.3] #. /configure -- prefix =/application/nginx-1.6.3 -- user = nginx -- group = nginx -- with-http_ssl_module -- with-http_stub_status_module16 [root @ Web-lnmp02 nginx-1.6.3] # make & make install # compile

 

Note:

Simple parameter description:

-- Prefix = PATH: Set the installation PATH

-- User = USER process user permission

-- Group = GROUP Process User group Permissions

-- The with-http_ssl_module activates the ssl feature

-- With-http_stub_status_module activation status information

 

Create a soft link:

 

 1 [root@Web-lnmp02 nginx-1.6.3]# ln -s /application/nginx-1.6.3/  /application/nginx 2 [root@Web-lnmp02 nginx-1.6.3]# ls -l /application/ 3 total 4 4 lrwxrwxrwx. 1 root root   25 Nov 28 21:18 nginx -> /application/nginx-1.6.3/ 5 drwxr-xr-x. 6 root root 4096 Nov 28 21:09 nginx-1.6.3 6 [root@Web-lnmp02 nginx-1.6.3]# cd nginx 7 -bash: cd: nginx: No such file or directory 8 [root@Web-lnmp02 nginx-1.6.3]# cd /application/nginx 9 [root@Web-lnmp02 nginx]# ll10 total 1611 drwxr-xr-x. 2 root root 4096 Nov 28 21:09 conf12 drwxr-xr-x. 2 root root 4096 Nov 28 21:09 html13 drwxr-xr-x. 2 root root 4096 Nov 28 21:09 logs14 drwxr-xr-x. 2 root root 4096 Nov 28 21:09 sbin

 

1.1.5 start the Nginx Service

 

 

 

1 [root @ Web-lnmp02 nginx] #/application/nginx/sbin/nginx # Start Nginx Service 2 [root @ Web-lnmp02 nginx] # lsof-I: 803 command pid user fd type device size/off node NAME4 nginx 5027 root 6u IPv4 23623 0t0 TCP *: http (LISTEN) 5 nginx 5028 nginx 6u IPv4 23623 0t0 TCP *: http (LISTEN) 6 [root @ Web-lnmp02 nginx] # netstat-lntup | grep nginx | grep-v grep7 tcp 0 0.0.0.0: 80 0.0.0.0: * LISTEN 5027/nginx

1.1.6 Test

Server address:

 

Browser access:

 

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.