Centos6.8 install nginx (1) and centos6.8 install nginx

Source: Internet
Author: User

Centos6.8 install nginx (1) and centos6.8 install nginx

Here, we will record the installation of nginx in detail.

1. Install gcc-c ++ in yum:

yum install -y gcc gcc-c++ [enter]

2. Download required dependent libraries: zlib, openssl, and pcre

wget http://nginx.org/download/nginx-1.11.13.tar.gz [enter]wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz [enter]wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.21.tar.gz [enter]wget http://www.zlib.net/zlib-1.2.11.tar.gz [enter]

3. Install dependency libraries: zlib, openssl, and pcre

Tar xvf nginx-1.11.13.tar.gz [enter] tar xvf openssl-1.1.0e.tar.gz [enter] tar xvf pcre2-10.21.tar.gz [enter] tar xvf zlib-1.2.11.tar.gz [enter] cd. /nginx-1.11.13 [enter]. /configure -- prefix =/usr/local/nginx -- with-pcre = .. /pcre2-10.21 -- with-openssl = .. /openssl-1.1.0e -- with-zlib = .. /zlib-1.2.11 [enter] make [enter] make install [enter] Note: The -- with option points to the source code path.

4. Modify the Configuration:

vi /usr/local/nginx/conf/nginx.conf [enter]

Note the following:

upstream  test {    server   127.0.0.1:18087;     server   127.0.0.1:28087;  }server {    listen       80;    server_name  localhost;    charset utf-8;    location /test {        root   html;        index  index.html index.htm;        proxy_pass        http://test;        proxy_set_header Host $host;        proxy_set_header X-Real-IP $remote_addr;        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;     }}

5. Check whether the configuration is correct:

/usr/local/nginx/sbin/nginx -t [enter]

The following information is correct:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

6. Start:

Start:/usr/local/nginx/sbin/nginx [enter] restart:/usr/local/nginx/sbin/nginx-s reload [enter]

7. Access:

 

Installed successfully!

Record it here first, and then add in detail ^_^ ~

 

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.