Nginx Installation Configuration Guide

Source: Internet
Author: User

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/5E/wKiom1YbVAHxXGywAAGjQDFA6PQ913.jpg "title=" Nginx.png "alt=" Wkiom1ybvahxxgywaagjqdfa6pq913.jpg "/>

Yum install gccgcc-c++ autoconf automake zlib zlib-devel OpenSSL openssl-devel pcre-devel make–y

Establish Nginx the system users and groups ( - R: set up users and groups in the specified system

Groupadd-r Nginx

Useradd-s/sbin/nologin-g nginx-r Nginx

Verify

ID Nginx

Configuration Nginx the module

./configure--prefix=/usr \

--sbin-path=/usr/sbin/nginx \

--conf-path=/etc/nginx/nginx.conf \

--error-log-path=/var/log/nginx/error.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_gzip_static_module \

--http-log-path=/var/log/nginx/access.log \

--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-http_stub_status_module

Make && make install

Start Nginx

/usr/sbin/nginx-c/etc/nginx/nginx.conf

To see if the service is started

Ps-ef | grep nginx

Netstat-antulp | grep nginx

When you start the error, because you have just manually specified a temporary directory, so you have to manually create a directory yourself.

Mkdir/var/tmp/nginx/client-pv

Nginx-c/etc/nginx/nginx.conf

Stop Nginx

Calmly close quit

Kill-QUIT $ (cat/var/run/nginx/nginx.pid)

Quick Stop

Kill-term $ (cat/var/run/nginx/nginx.pid)

Force the end of all nginx processes

Kill-9 Nginx

Smooth restart Nginx

Kill-hup $ (cat/var/run/nginx/nginx.pid)

/usr/sbin/nginx-t-c/etc/nginx/nginx.conf

can put rpm in the package Nginx Copy the script file and use it after you modify it.

Rpm2cpio nginx-1.9.0.rpm | Cpio-div Unpack RPM Package

CP nginx/etc/init.d/

chmod A+x/etc/init.d/nginx

Chkconfig--add Nginx

Chkconfig--list Nginx

Modify /etc/init.d/nginx script files, otherwise the service cannot be started with this script, because during the installation, these are the files and paths that you specify. (modified)

Prog=nginx

Nginx=${nginx-/usr/sbin/nginx}

CONFFILE=${CONFFILE-/ETC/NGINX/NGINX.CONF}

Lockfile=${lockfile-/var/lock/nginx.lock}

Pidfile=${pidfile-/var/run/nginx/nginx.pid}

sleepmsec=100000

Retval=0

Compiling nginx.conf detailed

Worker_processes 2 Here it is recommended to have several CPUs to give it a few processes.

Worker_connections 1024; Set the maximum number of connection requests (default 1024x768), and wait in the queue for more than once

Sendfile on; the memory is divided into two sections, a section of pepper User , another paragraph is Kernel , and when the user accesses the request, it accesses the kernel, and this is the process of logging the access to the memory, instead of having to read the kernel every time. Frequently accessed items are placed in memory. (whether this mechanism with caching is turned on)

gzip on; whether to start the compression function, when the large concurrency will be reflected.

Location similar to Apache of the Directory , while Root no absolute path is written next to it, so its root is the path you specified when you installed it.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5A/wKioL1YbXhGScjaUAACJnsQQyB8412.jpg "title=" 1.png " alt= "Wkiol1ybxhgscjauaacjnsqqyb8412.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5A/wKioL1YbXenzJQl3AABLTvd7UmM019.jpg "title=" 2.png " alt= "Wkiol1ybxenzjql3aabltvd7umm019.jpg"/>650) this.width=650; src= http://s3.51cto.com/wyfs02/M02/74/5A/ Wkiol1ybxf7i1aquaab5r-ywbas338.jpg "title=" 3.png "alt=" Wkiol1ybxf7i1aquaab5r-ywbas338.jpg "/>

and here's the / (Root) is from /usr/html This starts here and is defined below. (starting with HTML from the installation path )

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5E/wKiom1YbXkCilicbAAB5r-YWBas828.jpg "title=" 4.png " alt= "Wkiom1ybxkcilicbaab5r-ywbas828.jpg"/>

The configuration process for the virtual host.

I'm in a mainframe with a Ip corresponding to multiple domain names to configure, write in /etc/hosts in

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5E/wKiom1YbXoaCCUPcAABMW-2-Z_U051.jpg "title=" 5.png " alt= "Wkiom1ybxoaccupcaabmw-2-z_u051.jpg"/>

1 , the virtual host configuration process, /etc/nginx/nginx.conf

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5E/wKiom1YbXr6iVKTXAADALZ4jAQA871.jpg "title=" 6.png " alt= "Wkiom1ybxr6ivktxaadalz4jaqa871.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5E/wKiom1YbXuej0Xb8AAEn3QZLK8I445.jpg "title=" 7.png " alt= "Wkiom1ybxuej0xb8aaen3qzlk8i445.jpg"/>

finally: killall-1 Nginx (with Service Nginx Reload as a result)

To create a directory and write content in the directory, the command is index.html

Mkdir–p/var/www/virtual2

Mkdir–p/var/www/virtual

Verify:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5B/wKioL1YbXzrxHUG9AACt9KusK9Y463.jpg "title=" 8.png " alt= "Wkiol1ybxzrxhug9aact9kusk9y463.jpg"/>

A large number of regular expressions are used in the following configuration file.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5B/wKioL1YbX3nTbOHdAAF-kHyJVeQ176.jpg "title=" 9.png " alt= "Wkiol1ybx3ntbohdaaf-khyjveq176.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5E/wKiom1YbX5bA5YObAAKP8P5Tctk488.jpg "title=" 1.png " alt= "Wkiom1ybx5ba5yobaakp8p5tctk488.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5B/wKioL1YbX_jDNDUOAAGfQAx4ydo294.jpg "title=" 2.png " alt= "Wkiol1ybx_jdnduoaagfqax4ydo294.jpg"/>

Open this up.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5B/wKioL1YbYE3SieRBAAD3szZLENQ848.jpg "title=" 3.png " alt= "Wkiol1ybye3sierbaad3szzlenq848.jpg"/>

take this as an example, and then continue to modify the configuration. (warn is the log error level)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5E/wKiom1YbYF7BRflLAAEOfXj2TFo356.jpg "title=" 4.png " alt= "wkiom1ybyf7brfllaaeofxj2tfo356.jpg"/> Restart service, then log view

Tailf/var/log/nginx/www.example.com-error.log

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5B/wKioL1YbYMbhH3jFAAHDccEsBpA857.jpg "title=" 5.png " alt= "Wkiol1ybymbhh3jfaahdccesbpa857.jpg"/>

403 Error: Index file not found

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5B/wKioL1YbYRXBl1pQAACV2k7TpVs992.jpg "title=" 6.png " alt= "Wkiol1ybyrxbl1pqaacv2k7tpvs992.jpg"/> Then define the error page yourself

Edit/etc/nginx/nginx.conf

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5B/wKioL1YbYV3xHrt-AAGN8crtsU4103.jpg "title=" 7.png " alt= "Wkiol1ybyv3xhrt-aagn8crtsu4103.jpg"/> Then build the directory, and edit the contents of the error page

Mkdir/var/www/error

Cd/var/www/error

echo This is error > 40x.html

Then restart the service and verify the results:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5E/wKiom1YbYcugbd-wAAGj99PT8O0000.jpg "title=" 8.png " alt= "Wkiom1ybycugbd-waagj99pt8o0000.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5B/wKioL1YbYouhJKIbAAGIUACjxPk178.jpg "title=" 1.png " alt= "Wkiol1ybyouhjkibaagiuacjxpk178.jpg"/>

First of all: or continue to modify our configuration file, we have the original one more transformation can be.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5B/wKioL1YbYrahxQdxAAG0lw2Hqv4606.jpg "title=" 2.png " alt= "Wkiol1ybyrahxqdxaag0lw2hqv4606.jpg"/>

Service restarts and verifies results

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5E/wKiom1YbYuSh6ujOAAD2sV1aLHs750.jpg "title=" 3.png " alt= "Wkiom1ybyush6ujoaad2sv1alhs750.jpg"/>

I copied this file before.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5E/wKiom1YbYwmxBEnuAAFgU6gf-D4779.jpg "title=" 4.png " alt= "Wkiom1ybywmxbenuaafgu6gf-d4779.jpg"/> Aliases feature:

1 , edit /etc/nginx/nginx.conf configuration file.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5B/wKioL1YbY0qjaQ4CAAIEIant_wA637.jpg "title=" 5.png " alt= "Wkiol1yby0qjaq4caaieiant_wa637.jpg"/>

2 , creating directories and index files

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5B/wKioL1YbY32RchRkAACmpoKcavo721.jpg "title=" 6.png " alt= "Wkiol1yby32rchrkaacmpokcavo721.jpg"/>

3 , restart the service

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5B/wKioL1YbY6uDchXiAAD5uOS68_U737.jpg "title=" 7.png " alt= "Wkiol1yby6udchxiaad5uos68_u737.jpg"/>

4. Verification Results:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5E/wKiom1YbY86Czat5AABXk-2mBkw052.jpg "title=" 8.png " alt= "Wkiom1yby86czat5aabxk-2mbkw052.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5B/wKioL1YbZEGhL7jjAAGKJTKvRnk444.jpg "title=" 1.png " alt= "Wkiol1ybzeghl7jjaagkjtkvrnk444.jpg"/>

No explicit refusal is allowed for all

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5E/wKiom1YbZFiQL922AAKhLByajjY667.jpg "title=" 2.png " alt= "Wkiom1ybzfiql922aakhlbyajjy667.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5B/wKioL1YbZJqgSxZdAAD4Vk_KIlY110.jpg "title=" 3.png " alt= "Wkiol1ybzjqgsxzdaad4vk_kily110.jpg"/>

This module must be specified when compiling the installation, otherwise there is no such function.

--with-http_stub_status_module

1 , edit /etc/nginx/nginx.conf

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5B/wKioL1YbZR7hkru8AAJKLM36lbE743.jpg "title=" 1.png " alt= "Wkiol1ybzr7hkru8aajklm36lbe743.jpg"/>

2. Restart the service

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5B/wKioL1YbZU3QmKfSAADz0woGJYI220.jpg "title=" 2.png " alt= "Wkiol1ybzu3qmkfsaadz0wogjyi220.jpg"/>

3. Verification Results:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5B/wKioL1YbZXvjZwCVAADfQFUaCjw901.jpg "title=" 3.png " alt= "Wkiol1ybzxvjzwcvaadfqfuacjw901.jpg"/>

this Nginx_status before the directory is not established, according to the above operation can be done. This directory can also be encrypted, not let others see this result, this is can be passed to similar ngios and cacti for monitoring purposes of a function.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5F/wKiom1YbZ8rxg0DMAANZg8lJHBw411.jpg "title=" 1.png " alt= "Wkiom1ybz8rxg0dmaanzg8ljhbw411.jpg"/>650) this.width=650; src= http://s3.51cto.com/wyfs02/M00/74/5F/ Wkiom1ybz-tidlbpaagmvzlkyt0320.jpg "title=" 2.png "alt=" wkiom1ybz-tidlbpaagmvzlkyt0320.jpg "/>650) this.width= 650; "Src=" http://s3.51cto.com/wyfs02/M02/74/5F/wKiom1YbaBaxOXSVAALnTxwJv2Q286.jpg "title=" 3.png "alt=" Wkiom1ybabaxoxsvaalntxwjv2q286.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5C/wKioL1YbaFLC8xmrAAFJbsXF0tA382.jpg "title=" 4.png " alt= "Wkiol1ybaflc8xmraafjbsxf0ta382.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5F/wKiom1YbaFmANEbkAAFTkvx9jjc269.jpg "title=" 5.png " alt= "Wkiom1ybafmanebkaaftkvx9jjc269.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/5F/wKiom1YbaG_R393rAANHstMyF0E385.jpg "title=" 6.png " alt= "Wkiom1ybag_r393raanhstmyf0e385.jpg"/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/5F/wKiom1YbaJHwcw0YAAJsITiUWoc314.jpg "title=" 7.png " alt= "Wkiom1ybajhwcw0yaajsitiuwoc314.jpg"/>650) this.width=650; src= http://s3.51cto.com/wyfs02/M02/74/5F/ Wkiom1ybakscit0maajzdbnhgc4647.jpg "title=" 8.png "alt=" Wkiom1ybakscit0maajzdbnhgc4647.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/5C/wKioL1YbaObyTkLnAAHAJqaBs70575.jpg "title=" 9.png " alt= "Wkiol1ybaobytklnaahajqabs70575.jpg"/>






Nginx Installation Configuration Guide

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.