NginxV180 installation and configuration

Source: Internet
Author: User
: This article describes how to install and configure NginxV180. For more information about PHP tutorials, see. 1. install related support libraries:
Yum-y install gcc-c ++ autoconf
Yum-y install openssl-devel

Pcre: to rewrite, zlib: for gzip compression, ngx_pagespeed plug-in: front-end webpage access speed-up optimization plug-in
(1) pcre installation:
Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
Tar-zxvf pcre-8.36.tar.gz
Cd pcre-8.36
./Configure
Make & make install
Cd ../

Ln-s/usr/local/lib/libpcre. so.1/lib64/

(2) zlib installation:
Wget http://zlib.net/zlib-1.2.8.tar.gz
Tar-zxvf zlib-1.2.8.tar.gz
Cd zlib-1.2.8
./Configure
Make & make install
Cd ../

(3) openssl installation:
Wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
Tar-zxvf openssl-1.0.1c.tar.gz
Cd openssl-1.0.1c
./Config
Make & make install
Cd ../

(4) install pagespeed:
Wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.8.31.4-beta.tar.gz
Wget https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
Tar-zxvf v1.8.31.4-beta.tar.gz
Cp 1.8.31.4.tar.gz./ngx_pagespeed-1.8.31.4-beta
Cd ngx_pagespeed-1.8.31.4-beta
Tar-xzvf 1.8.31.4.tar.gz

II. install nginx
Create special users and user groups:
/Usr/sbin/groupadd www
/Usr/sbin/useradd-g www
Ulimit-SHn 65535

Wget http://nginx.org/download/nginx-1.8.0.tar.gz
Tar-zxvf nginx-1.8.0.tar.gz
Cd nginx-1.8.0
./Configure-user = www \
-Prefix =/usr/local/nginx \
With-http_ssl_module \
With-http_stub_status_module \
With-http_realip_module \
-Add-module =/home/yq/ ngx_pagespeed-1.8.31.4-beta

Make & make install

3. related configuration files:
1. nginx. conf

User www;
Worker_processes 4;

Error_log/var/log/nginx/error. log;

Pid/var/run/nginx. pid;

Events {
Use epoll;
Worker_connections 1024;
}

Http {
Upstream tomcat7 {
Server 127.0.0.1: 8090;
}
Upstream fdfs {
Server 192.168.77.32: 8888;
}
Pagespeed On;
Pagespeed FileCachePath "/var/cache/ngx_pagespeed /";
Pagespeed EnableFilters combine_css, combine_javascript;

include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;gzip  on;gzip_min_length     1000;gzip_buffers        4 16k;gzip_http_version   1.1;gzip_types  text/plain application/x-javascript text/css application/xml;  include vhost.conf; include vhost/*;

}

Vhost. conf is the default project, which is a virtual machine configuration,
Server {
Listen 80;
Server_name localhost;

    #charset koi8-r;    #access_log  logs/host.access.log  main;    location / {        root   html;        index  index.html index.htm;    }    #error_page  404              /404.html;    error_page   500 502 503 504  /50x.html;    location = /50x.html {        root   html;    }}

The following describes a typical virtual machine configuration:
Test. conf
Server {
Listen 80;
Server_name test.qq.cn;

#charset koi8-r;#access_log  logs/host.access.log  main;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header  Host $host;proxy_set_header  X-Real-IP $remote_addr;proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 30;proxy_read_timeout 60;proxy_buffer_size 4k;proxy_buffers 4 32k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;proxy_max_temp_file_size 128m;proxy_set_header Host $host;proxy_pass_header User-Agent;  location / {proxy_pass   http://tomcat7;}location /assets {        root html;index index.html;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {    root   html;}

}

The above describes how to install and configure NginxV180, including related content. if you are interested in the PHP Tutorial.

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.